C sharp Variables Data Types

Variables in any Programming language  are  the storage Locations where data is stored in Computer Memory. while storing data in variables their  interpretation is controlled with its types.
when we talk about C# we should know That  C# is strongly  typed language.  C sharp compiler  deal variable 's  type that  what type  of variable are they  mean to say retrieve values from variables  or  performing any operation all is done with the type of variables.

Csharp consist of the following Variable data types
  • Boolean Type
  • String Type
  • Integer Type
  • Floating Point 
Before Defining all of the above data type with example program first we should know how to declare variables in C#.
Declaring A variables in C-sharp
Declaring Variables means to assign Values to variables . We can Declare C sharp Variable as follow.
Type   Name = Value ;
first we have to specify type of our variable that we are going to declare then we shouldgive a proper name to our variable in C-sharp Program then  = sign which assign Value our variable. For example.
int z =10;
In above example we have a variable z  of integer type and having value 10.Similarly all of other data type variables can be declared by same rule first type then name and then value of variables.
Boolean Type Variables
In C# Boolean Variables are Declare with keyword bool which have two value True or False For Example.





  static void  Main(string[] args)
        {
            bool contact_no_correct = true;


            if (contact_no_correct == true)
            {
                Console.WriteLine("Number true ");
                Console.ReadLine();


            }


                else Console.WriteLine("Wrong Number");
        }
        }



In the above program we have a bool type variable (contact_no_correct) and who's value is true when run our program our program if the value is true  (contact_no_correct=true) number true will be printed on console window  if we change the value to false  (contact_no_correct=false) wrong number will be printed on screen.

String Type Variables
In C sharp we can Declare String variables  by using the keyword string , name of string variable and its value in double Quotes.

for Example

 
 static void  Main(string[] args)
        {
          string Name ="CsharpTutorialsFree.blogspot.com";
                Console.WriteLine(Name);
                Console.ReadLine();
  }

       

In the above Program we have a string variable Name  when we run the program the value in double quotes will be printed as message on  Console Window. 

Integer Type Variables

In C-sharp Integer type variables are Declared by using  keyword (int) .

for Example  : int a =10; as following program


 static void  Main(string[] args)
        {
                int  a =10;
                Console.WriteLine(a);
                Console.ReadLine();
  }
        }
when we run the program the number 10 will be displayed on screen this is because  we have a memory bucket a and having value 10 stored and that bucket .



Floating Point Variables


Floating point types are used in Csharp programs  when we  need to perform operations requiring fractional representations. They are declared using keyword float.

for Example :


 static void  Main(string[] args)
        {
                float  GPA =3.2;
               Console.WriteLine(GPA);
             Console.ReadLine(); 
  }
        }



In above program we have a  Floating point variable   GPA having value 3.2 when the program runs it will  3.2 on Console window.



C sharp Console Program

In my blog Csharp first Console Application was Hello CsharpTutorialsfree.blogspot.com the program  Csharp code is as follow
.

static void Main(string[] args)
{
  Console.WriteLine("Hello ! CsharpTutorialFree.blogspot.com");
  Console.ReadLine();

}
     Now we will see what did the above code for us and how did it works.
  1. The above line of code two things first they print a message on Console window (Black Screen).
  2. We have Console.ReadLine()  which tells the program to wait for the input from user.
we have a lot of text in first program like Console , WriteLine , ReadLine  etc what does all these really means we will understand this as we go deeper in our code that we just typed in .
As much the programming grows  this is the  main challenges for every programming languages that they must have better nouns ,verbs, Punctuation  from the existing ones.
Like other programming languages,when we learn how to write C sharp Applications we must have   familiar the dot.net Framework (.NET  FRAMEWORK). Now what the Dot.net Framework is ? we will learn in detail about the .Net Framework Later on but here we will just look at the Simple definition of Dotnet Framework which is "the .Net Framework is  a software which execute our Csharp code and runs our sharp applications".
As Programmer  we have  to look on every thing but the .Net Framework  make a lot of work easier for the Programmers  this helps the programmers   to don't worry about the low level details in  .Net framework  languages   like  allocating and De -allocating memory for the variables blah blah
Now the .NET Framework have the some basic library functions  as in our first program when we typed in Console.WriteLine("Hello Csharp");   we don't have to worry about memory management for our message  that how much memory  is need for our message to print   . we are just  have to think about what should be printed on screen we are not concern  how will our message will be  printed  on screen .when we look our code we have Console.WriteLine(); what does it Really do ? Answer is as follow.
In Console.WriteLine()  Console  Part is called Class. and the Write Line Part is called Method
We will learn in details about method and classes in our object Oriented part of C Sharp Programming.
All of the basic functionality is   in BCL (Base Class Library) of the .Net Framework.
this the console and write Line line is also a part of the .NET Framework Base Class Library.
the console bring a console window and the WriteLine Method Print our message that we have set through Parameters.

We use ReadLine()  Method of Console Class to pause our program  Until a User Press a key in there Keyboard.  if we  don't have ReadLine in our program  we will unable to see the our writeLine method though that method will be  correctly executed the console Window will close in mili seconds.
Note: When ever We want to print our message  on console window we should type our message in console class's WriteLine Method via Parameters.

Some method accepts Parameters and some of Don't Like ReadLine()  is a also a method in Console Class but they don't have parameter in our Program.

when we want to print our message we will have to pass our message through parameters. our message should be in (" "). what does the double quotes  (" ") do they tell the Csharp Compiler to just print that statement and its a lateral string (we will study about lateral strings and all data Type later on ).we can also print our message on console screen as follow.



static void Main(string[] args)
       {

              string Message  ="Hello ! CsharpTutorialsfree.blogspot.com";               
              Console.WriteLine(Message);
              Console.ReadLine();
       }


In above Program we just Store our message in a string called  Message and the we pass that string as parameter  to our Console class WriteLine Method .when we compile the out will be same for the as our first program.

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