You are on page 1of 3

Tuesday, 28 May 2013

awesome c sharp user interaction

Awesome C sharp user interaction

by santosh Hi.... guys today let's go ahead, in my previous article we tried our first c sharp code which was very simple code. You must be thinking that why to try coding stuff in notepad if we are having this Visual studio 2012 which look fab. Dear friends i think it is a good practice to start coding in notepad because notepad improves your coding abilities in comparison to visual studio which has awesome feature know as Intellisense. Friends when u will get confidence in notepad then i will take u to the vs 2012.

string Interaction : now again open notepad type this code

This code will try to take a text input from user and and will show his / her name as output of code. let's understand cod,e here in this code u have performed user interaction as i told u earlier Console is a class which is used to show text from predefined function WriteLine(); that's why we implement console class directly without using System namespace defined in previous post that namespace consist of class and System namespace consist of Console class so instead of using System namespace again and again we have mentioned it once on top of the code so that we do not need to use it again. so this code will show to the user "please enter your name". Once user see the instruction he will tries to enter his / her name in the visual studio command prompt 2012 and after pressing enter by user it's our responsibility to save his name in some place so we used a variable (name) to store that user name in name variable. And string is the data type which defines that only text values can be inserted in the name variable for doing all this we will be using

Console class again because console class has another wonderful function known as ReadLine() which takes input. After doing all this. We will display the text. for that purpose we used Console.WriteLine("your name is : "+name); where "your name is : " is static and + is concatenation operator (operators :- will talk about later) which tries to connect two different string. and variable name will display name of user. so it is simple try by yourself....

Integer interaction : Only string interaction will not be required by u. Integer interaction is also important lets see how to take integer input from user

in the main function Console.WriteLine("what is your age"); will display the instruction to the user what is his name int num= Convert.ToInt32(Console.ReadLine()); In this code user will provide the age by console.ReadLine(); which will be in string format for storing this data which looks like int but internally is string type is need to be manually converted into integer so for fulfilling that purpose we used Convert.ToInt32() function which will convert string data into integer data type.

After getting all this interaction coding in awesome c sharp we will understand console class in more detail. in my next post i will try to provides more about this console class thanks for reading it don't forget u r awesome.....

For more info please visit __________________________________________________________________ all right reserved @ 2013 vardana solutions __________________________________________________________________