C# - Variables and Expressions





Variables : Declaring our two variables is very easy. Simply type the following lines of code:

int x;
int y;

"int" is the C# term for integer, a mathematical term referring to a number that has no fractions or decimal values. Remember -- our goal in declaring variables is to tell the .NET Framework Runtime to save a place in memory for our numeric values. After that we can access our variables.

Expression : Type the following code:

int x = 7;
string y = "Bob";
string myFirstTry = x + y;
Console.WriteLine(myFirstTry);
Console.ReadLine();

If you run the application, you'll see that the console window prints out 7Bob. This is correct, because seven plus Bob equals 7Bob.

Now, add the following code:

int mySecondTry = x + y;

Comments

Popular posts from this blog

Deploy infopath form as content type when new form item

Populating InfoPath Drop Down List Box with SharePoint Fields Choice

How to set value of a field from sharepoint list