You will need to create a console-based application whose Main() method accepts ten integer values from the user and stores them in an array. Next, create a method that determines and displays the smallest and largest of the ten values. Then, pass the array to the method.
Save the file as SmallAndLarge.cs.
Next, create a GUI application whose button's Click() method accepts ten integer values from a TextBox and stores them in an array that is declared above the Click() method. After the ten entries have been made, call a method that sorts and displays the ten values from smallest to largest.
Save the file as SmallAndLargeGUI.cs.
\------------------------------------------------------------------------------\
VulpesPosted Feb 9, 2014, 9:13 AM
However, for the GUI app, it's not clear how the integers should be presented in the textbox. I've assumed they'll all be on the same line, separated by spaces, and that the sorted results will be displayed in a second textbox:
Of course, with these sorts of questions you never know to what extent you're supposed to check for valid input which is half the battle in 'real life' apps. I've done very little checking in the above.
VulpesPosted Feb 10, 2014, 12:59 PM
So at the command line, if you type this, it will create somenumbers.exe:
csc /t:winexe sortnumbers.cs
You can then run it from the command line by typing : somenumbers.exe at the prompt.
SUNIL GUTTAPosted Feb 10, 2014, 8:13 AM
you done something to convert the windows forms code from command line long back ..
Actually i need the above code of windows form to make it into executable thing who don't have vs 2010 ..
Cheers mate
SUNIL GUTTAPosted Feb 9, 2014, 12:51 PM
Actually there is some foolish reason i am using int16 Lol .
I am thinking like when we use for storing small variables like a=2 .. why to waste so much memory like that . That's y i sometimes i use int16 over int32 ..
Although GC will take care of memory lol i am taking care of memory before GC is taking he he :)
Thank you for help friend :)
Cheers
VulpesPosted Feb 9, 2014, 12:29 PM
The only thing I'd quarrel with in your versions is the use of Convert.ToInt16 rather than Convert.ToInt32 (or int.Parse).
In C# (and also Java), ints are always 32-bit signed integers. This means that, whilst Convert.ToInt16 works for integers up to approx 32K, it returns a short and the CLR then has to convert it to an int which consumes some extra cycles.
This differs from the position under C/C++ where the size of an int depends on the platform and can be either 16 or 32 bits in length.
SUNIL GUTTAPosted Feb 9, 2014, 12:11 PM
1)
2) public partial class SmallAndLargeGUI : Form