C # Programming Overview A simple C # program
Identifier
An identifier is a string used to name variables, methods, parameters, and many other program structures that will be elaborated later.
Key words
All C # Keywords are made up of lowercase letters, but. NET type name using the Pascal casing convention.
Main: The starting point of the program
- The executable starting point of a C # program is the first instruction in main
- Main first letter must be capitalized
Output text from a program
The BCL (base Class Library) provides the console class (in the System namespace), which contains methods for entering and outputting data to the console.
Write
Console.Write ("This is trivial text.");
WriteLine
System.Console.WriteLine ("This is Text1."); System.Console.WriteLine ("This is Text2."); System.Console.WriteLine ("This is Text3.");
format string
Console.WriteLine ("Both sample integers is {0} and {1}.", 3,6);
Multiple tags and values
Console.WriteLine ("Three integers is {1},{0} and {1}.", 3,6);
Formatting numeric strings
Console.WriteLine ("The Value:{0}.", 500); Console.WriteLine ("The Value:{0:c}.", 500);
Justification specifier
int myint=500; Console.WriteLine ("|{ 0,10}| ", myInt); Console.WriteLine ("|{ 0,-10}| ", myInt);
Format field
Double mydouble=12.345678; Console.WriteLine ("{0,-10:g}--general", mydouble); Console.WriteLine ("{0,-10}--default,same as General", MyDouble); Console.WriteLine ("{0,-10:f4}--fixed point,4 Dec places", MyDouble); Console.WriteLine ("{0,-10:c}--currency", mydouble); Console.WriteLine ("{0,-10:e3}--sci.notation,3 dec places", MyDouble); Console.WriteLine ("{0,-10:x}--hexadecimal integer", 1194719);
Standard numeric format specifier
Comments
C # Programming Overview