Saturday, 15 April 2017

CSHARP VARIABLE AND DATA TYPES ~ mkniit

C# VARIABLE AND DATA TYPES

Before learning a programming technique, you must first master the programming language in question. Let's say you want to learn C # programming, you must learn first how to communicate with C # programmingenvironment that is by understanding the basics – and understand basic programming languages in use in C#.
  
Data Types In C #

In C # there are two types of data, namely:
C# VARIABLE AND DATA TYPES

VARIABLE

During the execution of the program, the data used by the program will be stored temporarily in memory. Any data that is used in programming C # should be defined in advance. To declare a variable or data, use syntaxsuch as the following:
           < data type > <variable>;
Suppose you want to define a variable named i and integer data type. Then for writing quite like below:
           Int I;
For more details, about East you can see it in the example in the following program:
1. Create a new application project. In Visual Studio, on the menu click File> New  > Project. For more details,see the following menu on the display.

C# VARIABLE AND DATA TYPES

2. Then will appear the window New Project like the look below.

C# VARIABLE AND DATA TYPES

3. Write down the name of the project that will be created on a field Name. Specify the directory storage projectby accessing the field Location. Next, give the name of the solution in the Solution Name. Then click OK.
4. Then you will have created the framework of main program listings by Visual Studio. Here's how it looks.
 C# VARIABLE AND DATA TYPES

5. Next step, write the following program listing:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;


Namespace ConsoleApplication1
{
            Class Program
            {
                        Static void Main(string[] args)
                        {
                                    string Name;

                                    Name = “My name is Tutorials Programmings”;

                                    Console.WriteLine(Name);

                                    Console.ReadLine();

                        }

            }

}

6. After you write down the program listings, press the F5 key to run the program.
C# VARIABLE AND DATA TYPES

In the above program listing can be seen that the first time, the program will declare the variable with a value of"my name is Programmings Tutorials". Then print the variables on the console with the command Console.WriteLine (Name);.

VARIABLES OR CONSTANTS SYSMBOL

Variable constants are one type of fixed or variable has the value cannot be changed. To write the variablesconstant, the syntaks is:

             Const <datatype> <variable name> = < the values of the constants>; 

Then write the following program listing:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;

Namespace ConsoleApplication1
{
            Class Program
            {
                        Static void Main(string[] args)
                        {

                                    const double PI = 3.14;

                                    Console.WriteLine("The Values of  the constants = " + PI);

                                    Console.ReadLine();

                        }

            }

}

The value of the constants in the listings above program declared by listing const double PI = 3.14;. After the constant is declared, then the program will print in the console programs by using the command Console.WriteLine ("The Values of the constants.php =" + PI);.

C# VARIABLE AND DATA TYPES

No comments:

Post a Comment