c sharp user input console

Some time we need a user input for our programs . our program will wait for user input and then our program will evaluates user's input and then our Program can execute further.  For Example :


 Now the above Program will  take 2 Numbers from user and then will add user Numbers.
we will see in details  how the above program works indeed .

Getting First Number from User .

 First We Prompt User to Enter his/her First Number on Console Window. When user types a Number we have Declared a Integer Type x the User value will be stored in the Variable x . (Int.Parse) converts the User Typed value In 32-bit Signed Integer. (When ever a user Types on console Windows the Input are mostly consider as String in C Sharp so we have to convert the value to Integers in order to do some arithmetical operations ).
when the User Types his/her  First Value will be stored in  Int x .

Now for The 2nd value will type as follow.

 
Again the User's 2nd value will be stored in  in variable y . Now finally we will have to type as follow.

 
 We  Declare a Variable of Integer type  named sum and then we add value of x and value of y and then assign  the value to sum .finally when program run will take two values will added them and the sum will be printed on console window.


No comments:

Post a Comment

Sending SMS Via Windows Form Application Using any Android Smart Phone  Source Code  using System ; using System . C...