|
This is okay, why doesn't it work?
Replace answer = i / j; with Console.WriteLine(j/i); to see the output.
Note that I replaced i/j through j/i, so that the divisions have a more readable order.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi Greeeg,
I guess it works but not the way i liked it to be.
It suppose to print this:
1 / 1 =
2 / 1 =
3 / 1 =
4 / 1 =
etc.
2 / 2 =
4 / 2 =
6 / 2 =
etc.
3 / 3 =
6 / 3 =
9 / 3 =
etc.
4 / 4 =
8 / 4 =
12 / 4 =
etc.
5 / 5 =
10 / 5 =
15 / 5 =
20 / 5 =
etc.
But instead of printing it like this, it prints this:
1 / 1 =
2 / 1 =
3 / 1 =
etc.
1 / 2 =
2 / 2 =
3 / 2 =
etc
1 / 3 =
2 / 3 =
3 / 3 =
etc
Like this up until "x / 10 =".
Do i have to make anther for statement in those 2 for statements?
|
|
|
|
|
Somehow like this:
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
for (int k = j; k < j*5; k+=j)
{
Console.WriteLine(k + "/" + i);
}
}
}
It's bugged, but I don't know where the error is right now.
Just play around a bit with it.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
Thank you, i'll try a few things with it!
|
|
|
|
|
for(int i = 1 ; i < 11 ; i++ )
for(int j = 1 ; j < 11 ; j++ )
Console.WriteLine(j * i + "/" + i);
I think this is simpler.
|
|
|
|
|
Hi Adis,
That worked, thank you very much!
|
|
|
|
|
lets say I have 5 buttons and 1 text box
I want to get the text from all the button
so if I click one of the button the text of the same button
will be written in the textbox but!
I can use 5 event's
I only need to use on event.
please someone help me
|
|
|
|
|
Register the same event handler to all buttons, cast the sender parameter of the event handler from object to Button and finally access the button's text.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi...
What is the command for 'EchoOff' & 'EchoOn' in C# for SerialPort communication in C#.
Regards,
Vinay
|
|
|
|
|
Sounds like what you are really talking about it the echo from a modem, the serial port itself has no echo. If I am right it all depend on the modem you are using. Most "Hayes" modems use &E0 and &E1.
|
|
|
|
|
Hi!
I found this text when I serched MSDN for "unmanaged exceptions". Does anyone knows what it means?
""
Managed Code
In managed code, you cannot continue execution in the same thread after an unhandled exception. The thread terminates. If it is the program thread, the program itself terminates.
""
I have an application that simply terminates, NO exceptions, NO fault codes, NO dialog box saying: "an unhandled excep..."
|
|
|
|
|
Hi!
When does this occurr? Does your application use interop? In that case chances are that something is wrong there (struct or function declarations slightly wrong).
But without any code it's impossible to say for sure.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Judge.dll defines following two struct types and exports the method
i4IcsJudgeStartGame. In csharp code there is a wrapper for this method.
Building succeeds, but running get an exception:
{System.Runtime.InteropServices.MarshalDirectiveException}
{"Can not marshal parameter #4: Invalid managed/unmanaged type combination
(this value type must be paired with Struct)." }
:Please help me, what's the problem in these code.
============================ in Judge.dll ========================
struct IcsGameRule
{
int fgHasTimeLmt;
unsigned short int u2RangZi;
unsigned short int u2TieMu;
};
struct IcsGameTime
{
unsigned char ucHour;
unsigned char ucMiniute;
unsigned char ucDumiaoLen;
unsigned char ucDumiaoCnt;
};
DllExport int i4IcsJudgeStartGame(unsigned int Judge,
int Type,
struct IcsGameRule Rule,
struct IcsGameTime Time);
===================== in csharp wrapper ==================================
[StructLayout(LayoutKind.Sequential)]
public struct GameRule
{
public int HasTimeLmt;
public ushort RangZi;
public ushort TieMu;
}
[StructLayout(LayoutKind.Sequential)]
public struct GameTime
{
public byte Hour;
public byte Miniute;
public byte DumiaoLen;
public byte DumiaoCnt;
}
[DllImport("judge.dll")]
private static extern int i4IcsJudgeStartGame(
[MarshalAs(UnmanagedType.U4)]uint judge,
[MarshalAs(UnmanagedType.I4)]GameType type, //GameType is enum
[MarshalAs(UnmanagedType.LPStruct)]GameRule rule,
[MarshalAs(UnmanagedType.LPStruct)]GameTime time);
|
|
|
|
|
Hi!
Try replacing [MarshalAs(UnmanagedType.LPStruct)] with ref .
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
It does work after the replacement.
Thank you!
|
|
|
|
|
Iam adding controls onto win form with this code:
Name, position, path and order, Iam reading from XML. That's OK.
name = lng.node.Current.GetAttribute("Namespace", "");
position = lng.node.Current.GetAttribute("Position", "");
path = GetModulePath(int.Parse(lng.node.Current.GetAttribute("BoundToID", "").ToString()));
order = lng.node.Current.GetAttribute("Order", "");
ass = Assembly.LoadFile(Application.StartupPath + "\\" + path);
t = ass.GetType(name);
o = Activator.CreateInstance(t);
uc = ( (UserControl)(o) );
I have module class that is a based class for module, and every control that has to behave like module have to be inherited from this class.
I have implemented collapse/expand option in module class and adding this button is handeled in module class, so when I inherit from module class, that control gets its own collapse/expand button.
I want to raise an event when I click on that collapse/expand button, but to catch the event in main form where Iam loading this modules, so I need a code how to create event handler with dymanically created events.
Normaly, I will do like so:
this.someModule.ClickedCollapseExpandButtonEvent += ClickedCollapseExpandButtonHandler(someModule_ClickedCollapseExpandButtonEvent);
And then
private void someModule_ClickedCollapseExpandButtonEvent(object sender, EventArgs e)
{
}
I hope you've understood.
|
|
|
|
|
You do it the same way. Just substitute this.someModule with the reference to the control.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for the reply, but I cant do it, becouse referenced control doesent have a definition for that event, even if I've created this event, it wont compile.
UC is type of UserControl (like you can see in code in my first post), and on execution, it gets a reference to loaded control, so I can't figure it out how to raise an event.
I can't explain well, but I hope youll understand.
|
|
|
|
|
Cast the reference to your class instead of UserControl.
---
b { font-weight: normal; }
|
|
|
|
|
Hi.
I did what you told me, but I have no clue what next to do to raise that event.
Can you provide some code sample?
Keep in mind that control is dynamically created so therefore, events are created dynamically as well.
Thank you.
-- modified at 7:58 Monday 13th November, 2006
|
|
|
|
|
Hi.
I have spent a lot of time thinking and Googling, and so far I found this » http://msdn2.microsoft.com/en-us/library/ms228976.aspx.
Code below is taken from this link, and when its executed, I get an error that is miHandler is null.
I cant figure it out why, and does this code surely do what I want?
I have CollapseHandler event and proper delegate and surely I hace CollapseHandlerVoid for running the code when event gets fired.
EventInfo evClick = t.GetEvent("CollapseHandler");
Type tDelegate = evClick.EventHandlerType;
MethodInfo miHandler = typeof(frmMain).GetMethod("CollapseHandlerVoid");
Delegate d = Delegate.CreateDelegate(tDelegate, miHandler);
MethodInfo AddHandler = evClick.GetAddMethod();
Object[] addHandlerArgs = { d };
AddHandler.Invoke((object)this, addHandlerArgs);
Help, please.
|
|
|
|
|
Solved...
((YuGit.DesktopModules.Module)uc).CollapseHandler += new YuGit.DesktopModules.Module.CollapsedEvent(frmMain_CollapseHandler);
|
|
|
|
|
Who can show me how to catch message in Yahoo Messenger by C#.
suppose that, when I send a message, then a image will be sent.
|
|
|
|
|
This is juat a hint that yahoo messenger uses InternetExplorer control for displaying messages... You need to get control of the underlaying IE if you need to trap yahoo messages...
|
|
|
|
|
hi
i am use VC# 2005 and i want to connect to sqlserver 2000 from client to server,when i want to add datasource to my app and enter server name to
specific textbox and click Test connection the following error shown me :
Login failed for user 'VAZIRI-B8765F7F\Guest'.
How to solve my problem ?
very thanks
|
|
|
|