C# Programming Overview
A simple C# program
identifier
An identifier is a string that names variables , methods , parameters , and many other program constructs that will be explained later .
keywords
All C# keywords consist of lowercase letters , but .NET type names use the Pascal case convention.
Main: the starting point of the program
- The executable starting point of the C# program is the first instruction in Main
- The first letter of Main must be capitalized
output text from a program
BCL (Base Class Library, base class library) provides the Console class (in the System namespace), which contains methods for inputting 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("Two sample integers are {0} and {1}.",3,6);
Multiple tags and values
Console.WriteLine("Three integers are {1},{0} and {1}.",3,6);
format a string of numbers
Console.WriteLine("The value:{0}.",500); Console.WriteLine("The value:{0:C}.",500);
★ Alignment 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 Number Format Specifier
Notes
Note: Ctrl K+Ctrl C
Uncomment: Ctrl K+Ctrl U
Author: Moonache
Source: http://www.cnblogs.com/moonache/