myDouble);Console.WriteLine("{0

时间:2022-01-24 02:53:24

C#编程概述 一个简单的C#措施

myDouble);Console.WriteLine("{0

myDouble);Console.WriteLine("{0

标识符

标识符是一种字符串,用来定名变量、要领、参数和许多后面将要论述的其他措施布局。

myDouble);Console.WriteLine("{0

myDouble);Console.WriteLine("{0

关键字

所有C#关键字都由小写字母构成,但是.NET类型名使用Pascal巨细写约定。

myDouble);Console.WriteLine("{0


myDouble);Console.WriteLine("{0

Main:措施的起始点

C#措施的可执行起始点在Main中第一条指令

Main首字母必需大写

从措施输出文本

BCL(Base Class Library,基类库)供给Console类(在System定名空间中),该类包罗了输入和输出数据到控制台的要领。 
Write

Console.Write("This is trivial text.");

myDouble);Console.WriteLine("{0

 
WriteLine

System.Console.WriteLine("This is text1."); System.Console.WriteLine("This is text2."); System.Console.WriteLine("This is text3.");

myDouble);Console.WriteLine("{0

 
格局字符串

Console.WriteLine("Two sample integers are {0} and {1}.",3,6);

myDouble);Console.WriteLine("{0

 
多重符号和值

Console.WriteLine("Three integers are {1},{0} and {1}.",3,6);

myDouble);Console.WriteLine("{0

 
格局化数字字符串

Console.WriteLine("The value:{0}.",500); Console.WriteLine("The value:{0:C}.",500);

myDouble);Console.WriteLine("{0

myDouble);Console.WriteLine("{0

myDouble);Console.WriteLine("{0

对齐说明符

int myInt=500; Console.WriteLine("|{0,10}|",myInt); Console.WriteLine("|{0,-10}|",myInt);

myDouble);Console.WriteLine("{0

格局字段

myDouble);Console.WriteLine("{0


myDouble);Console.WriteLine("{0

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);

myDouble);Console.WriteLine("{0

myDouble);Console.WriteLine("{0

标准数字格局说明符

myDouble);Console.WriteLine("{0


myDouble);Console.WriteLine("{0

注释

myDouble);Console.WriteLine("{0

myDouble);Console.WriteLine("{0