Skip to main content

Variables

Variables
You may have been using variables and constants in since your 3rd grade. In any programming language same concept of variables is used which covers more than half of your code. Now is you have worked in C++ or Java or Python or any other programming language you may have used variables. If you are new to programming and you have started with C# its totally OK because you don't need any degree to learn programming.
Now what are the variables, to be precise variables are the empty shells which can be filled to their limit and their value can variate with the passage of time as required and manipulated on desire. 
Their are few types of variables:
Types Examples
Integral Types stype, byte, short, ushort, int, unit, long, ulong and char
Floating Point Types Floating and Double
Decimal Types Decimal
Boolean Types True or False value, as assigned
Nullable Types Nullable Data Types

Declaration
Moving on we have some rules for declaring a variable. 


  • A variable must start with an alphabet or "-".
  • Good programming practice is to chose a noun as a variable name
  • There should be no empty space in between a variable name
  • Variables are case sensitive
  • Appropriate Data must be used
  • If you want to declare a Nullable variable ? must be used at the end of the data type.

  • Lets see an example

    namespace Variables
    {
        class Program
        {
            static void Main(string[] args)
            {//integer
                int data1;
                //character
                char data2';
                //float
                float data3;
                //double
                double data4;
                //Nullable
                int? data5;
                //Boolean
                Boolean data6;
                //decimal
                decimal data7;
            }
        }
    }
    

    Initializing a variable

    To initialize a variable an assignment operator is used. Usually in common language we name the assignment as equal sign. Most importantly one should know what is actually initializing a variable, it's nothing but first time assignment of a variable. As C# is a purely object oriented language so we will talk in context of classes. We can initialize the variables when they are declared (but finals are initialized when declared strictly), we can also initialize the variables at run time.

    Lets see an example

    namespace Variables
    {
        class Program
        {
            static void Main(string[] args)
            {//integer
               int data1=0;
               //character
               char data2='0';
               //float
               float data3=(float)0.0;
               //double
               double data4=0.0;
               //Nullable
               int? data5=null;
               //Boolean
               Boolean data6=false;
               //decimal
               decimal data7=3.3m;
            }     } }
    
    

    Share your views comment below.






    Comments

    Popular posts from this blog

    Theory of Automata Assignment #2 Part #2 Regular Expression # 6 The set of strings over {a,b} that contain at least two a's or exactly two b's. (a+b)*(a)(b*)a(a+b)*+a*b(a*)b(a*) Regular Expression # 7 The set of strings over {a,b} that contain even length but not multiple of 3 (aa*)(aaa^) Regular Expression # 8 The language over {a,b}contains exactly one double letter.   (ε + b)(ab) ∗aa(ba) ∗(ε + b) + (ε + a)(ba) ∗ bb(ab) ∗(ε + a)

    TA ASSIGNMENT 1 PART 3

    Theory of Automata Assignment #1 Part #3 Recursive Definition #11: Language of Expressions having at least one operator defined on  Σ ={+,-,*,/,a,b}  Step 1#- a+b ,a*b,a/b and a-b are in L Step 2#- If x is in L then x+x,x-x,x*x,x/x is also in L Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #12: Language of string starting and ending on different alphabet defined on  Σ ={a,b} Step 1#- ab and ba are in L Step 2#- If x is in L then axb,and bxa are also in  Σ*.   Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #13: Language of even numbers Step 1#- 0 and 2 are in L Step 2#- If x is in L then x+2 and x-2 is also in L .   Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #14: Language of negative integers d...

    Insta, Twitter and Facebook Desktop To Mobile Version

    Hello azumavengers and welcome to my blog. Today we are going to talk about some insta, twiter and fb tricks. Web Api's Tricks Facebook, Insta and twitter Desktop To Mobile Version By Codezila  Like our Facebook page, its link is given below Codzila Facebook Page