Now we will print our variables to the screen with Console.WriteLine(); command.
We can start with our previus variables.
Example 1
Printing out single string variable:
string name = "Bill";
Console.WriteLine(name);
Example 2
Printing out multiple string variables:
string name = "Bill", lastname = "Gates";
Console.WriteLine(name+lastname);
In the example 2 the result shown as "BillGates" there is no space between the variables for this we should manualy add a space.
Example 2.1
Printing out multiple string variables with space between them:
string name = "Bill", lastname = "Gates";
Console.WriteLine(name+" "+lastname);
In the next post we will study on printing integer variables.
About C# Coding
C#, C Sharp, Coding, Code Examples, C# For Beginners
Search This Blog
Friday, September 24, 2010
Wednesday, September 22, 2010
Variables Part 2
In this part of the variables we will study integer type variables. Integer type variables can hold numbers for math process without this type variables we can not make any math process.
Example 1
Identifying a integer variable:
int number;
Example 2
Assing a value to this variable:
number = 5;
Example 3
We can assing value to a variable while we creating it:
int number = 5;
Example 4
We can create multiple variables and assing values at one time:
int number = 5, number1 = 6;
In the next post we will study writing our variables to the screen in console aplications.
Example 1
Identifying a integer variable:
int number;
Example 2
Assing a value to this variable:
number = 5;
Example 3
We can assing value to a variable while we creating it:
int number = 5;
Example 4
We can create multiple variables and assing values at one time:
int number = 5, number1 = 6;
In the next post we will study writing our variables to the screen in console aplications.
Monday, September 20, 2010
Variables
In C# we have various variables, in this post we study "string" type variable. "String" variables can contains all type of symbols. Whlie assing a value to string variable we must use the (") symbol of the begining and the end of the value.
Example 1
Identifying a string variable:
string name;
Example 2
Assing a value to this variable:
name = "Bill";
Example 3
We can assing value to a variable while we creating it:
string name = "Bill";
Example 4
We can create multiple variables and assing values at one time:
string name = "Bill", lastname = "Gates";
In the next post we will study "integer" type variables.
Example 1
Identifying a string variable:
string name;
Example 2
Assing a value to this variable:
name = "Bill";
Example 3
We can assing value to a variable while we creating it:
string name = "Bill";
Example 4
We can create multiple variables and assing values at one time:
string name = "Bill", lastname = "Gates";
In the next post we will study "integer" type variables.
Hello World Our First Code (Console)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
}
Subscribe to:
Posts (Atom)