WinForms, yeh? And I guess you mean .NET v.4 and
System.Numerics.BigInteger
, right?
(There is no such type as "large_int", so I did not know what to think about. No matter, use the type you want: the rest of the code will be exactly the same; see below.)
Then, instead of you pseudo-code you'll have something like this:
System.Numerics.BigInteger Example(System.Numerics.BigInteger u, System.Numerics.BigInteger v) {
return u + v;
}
Ok, then you suppose to have some 3 controls to hold string representation of your big integers, plus your button:
TextBox
TextBoxLeftOperand,
TextBoxRightOperand;
TextBoxBigIntegerTestResult;
Button MyButtonTextBoxBigIntegerTest;
And you will need a code for a hander:
void BigIntegerTestClickHandler() {
System.Numerics.BigInteger u =
System.Numerics.BigInteger.Parse(TextBoxLeftOperand.Text);
System.Numerics.BigInteger v =
System.Numerics.BigInteger.Parse(TextBoxRightOperand.Text);
TextBoxBigIntegerTestResult.Text = Example(u, v).ToString();
}
Expect getting exceptions thrown from the code above.
Finally, you'll need to setup your button event. You can do it right after the form is constructed (or later, but certainly before the user can actually click this button):
MyButtonTextBoxBigIntegerTest.Click +=
(sender, args) => { BigIntegerTestClickHandler(); };
My advice: always use the syntax above, not the gravely obsolete syntax used in Microsoft's auto-generated code. The benefits: you don't have to specify exact type for event handler arguments, which is especially good if you're not using the argument (very typical case); also, you're not bound to having same arguments in the handler (otherwise you would have to specify the arguments
sender
and
args
even if you're not using them). Finally, you're allowed to avoid writing a hander like
BigIntegerTestClickHandler
as a separate method at all; instead, you could simply put a body of this method directly between curly brackets of the above codelet.
Note: Perhaps, the numeric part is overkill; and you meant some simple integer type (
BigInteger
is extremely sophisticated type supporting unlimited presision. (And be ready to hang your computer by certain operations with really big intermediate numbers.)). Not to worry. Just use the same code and replace
System.Numerics.BigInteger
with whatever type you want.
That's it.
Is this something you wanted?
Please do not down-vote this answer because it does not answer the question posed!
I think nobody can say for sure what the author of the question means. This is just an introductory suggestion in hope it can be helpful. As soon as author of the question answers my questions and resolve the controversies, I'll be able to give a final answer.