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:
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.
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.
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();
}
}
}
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);.
No comments:
Post a Comment