前言:本資料根據(jù)【1】整理知識(shí)要點(diǎn),其內(nèi)容應(yīng)當(dāng)是全面的??晒┎殚?、復(fù)習(xí)參考。
參考資料:
【1】《BEGINNING VISUAL C#? 2012 PROGRAMMING》
【2】
C# 語(yǔ)句大全!1、 C#程序基本結(jié)構(gòu)和語(yǔ)法要點(diǎn)
Here, you’ll take a closer look at the console application example and break down the structure a bit. Here’s the code:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;
namespace ConsoleApplication1{ class Program { static void Main(string[] args) { // Output text to the screen. Console.WriteLine("The first app in Beginning C# Programming!"); Console.ReadKey(); } }}
(1)所有的C#程序后綴為.cs
(2)編輯時(shí),為使用代碼大綱(代碼折疊)功能,可如下:
#region Using directivesusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;#endregion
以#開(kāi)頭的內(nèi)容可視為預(yù)指令,他不是C#的關(guān)鍵字。編輯時(shí)代碼可折疊為1行。
(3)區(qū)分大小寫(xiě)。
(4)語(yǔ)句中的空格將不予考慮。
(5)分號(hào)“;”為一條語(yǔ)句的結(jié)尾。一條語(yǔ)句可書(shū)寫(xiě)在2行或多行。
(6)聲明語(yǔ)句后面不要分號(hào)“;”
(7)注釋的方式有三種:
? /* */
/* */
特點(diǎn):以“/*”開(kāi)始,可書(shū)寫(xiě)于多行,只直到有“*/”結(jié)束。
? //
//
特點(diǎn):以“//”開(kāi)頭,只能書(shū)寫(xiě)于一行??蔀閱为?dú)的一行,也可以放在一條語(yǔ)句的分號(hào)之后。
? ///
///
與//相同。不同的是該方法可由VS提取內(nèi)容。
(8)占位符標(biāo)簽
程序中的占位符標(biāo)簽類(lèi)似于匯編語(yǔ)言中的程序指針地址。下圖中第2行和第1行為一個(gè)標(biāo)簽,因其間無(wú)分號(hào)相隔。
<code line 1, statement 1>;<code line 2, statement 2> <code line 3, statement 2>;
? 關(guān)于類(lèi)、接口、Sub子程序和變量修飾符
類(lèi),以某種參數(shù)實(shí)例化后即成為對(duì)象。我這樣理解:對(duì)象就是程序中的實(shí)體,一個(gè)UI或一個(gè)數(shù)據(jù)結(jié)構(gòu),類(lèi)是一些實(shí)體的共有屬性的集合。類(lèi)可以通過(guò)XAML標(biāo)記語(yǔ)言編程設(shè)計(jì)而定義,這種類(lèi)一般用作UI或UI元素;類(lèi)也可以通過(guò)C#代碼編程設(shè)計(jì)而定義,通過(guò)C#代碼,既可以定義用作UI或UI元素的類(lèi),可以定義數(shù)據(jù)結(jié)構(gòu)的類(lèi)。UI或UI元素的類(lèi)不是本篇討論的內(nèi)容。
C#編程與匯編語(yǔ)言編程完全不同。后者是為CPU編寫(xiě)代碼,程序是順序結(jié)構(gòu),設(shè)計(jì)人員要用的是CPU。C#語(yǔ)言編程不是順序結(jié)構(gòu),基本與CPU無(wú)關(guān),用的是微軟的操作系統(tǒng),運(yùn)行時(shí),不是C#代碼在運(yùn)行,而是操作系統(tǒng)在運(yùn)行,C#代碼為操作系統(tǒng)提供一些任務(wù),由微軟操作系統(tǒng)完成。這些代碼必須符合微軟操作系統(tǒng)的規(guī)定,微軟把這些規(guī)定商業(yè)包裝成.Net,為便于編程者使用.net,微軟設(shè)計(jì)了WPF、XAML、C#三個(gè)東西,你就是用這三樣?xùn)|西來(lái)設(shè)計(jì)你的應(yīng)用程序。XAML用于設(shè)計(jì)UI,C#代碼負(fù)責(zé)UI所體現(xiàn)的信息的處理。UI上產(chǎn)生“事件”,C#代碼處理事件,微軟稱(chēng)此對(duì)事件處理的程序?yàn)椤胺椒ā?,方法就是一個(gè)個(gè)的sub子程序。
定義變量的場(chǎng)合因此有三處,類(lèi)的內(nèi)外,sub的內(nèi)外。類(lèi)型則有臨時(shí)有效或永久有效。C#通過(guò)變量修飾符為變量設(shè)定類(lèi)型。
2、 名稱(chēng)空間、類(lèi)和接口
2.1 定義和使用名稱(chēng)空間
? namespace語(yǔ)句。定義名稱(chēng)空間。語(yǔ)法:
namespace LevelOne{ // code in LevelOne namespace // name "NameOne" defined}// code in global namespace
? using語(yǔ)句。使用名稱(chēng)空間。語(yǔ)法:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ ...}
2.2 定義類(lèi)、聲明類(lèi)的屬性
? internal。該修飾符聲明類(lèi)是內(nèi)部的,僅本項(xiàng)目使用。可省略。internal class MyClass{// Class members.}
? public。聲明類(lèi)是公共的,可由其他項(xiàng)目中的代碼來(lái)訪問(wèn)。public class MyClass{// Class members.}
? abstract。抽象類(lèi)。不能實(shí)例化,只能繼承。下例中public亦可為internal。public abstract class MyClass{// Class members, may be abstract.}
? sealed。密封類(lèi)。不能繼承。下例中public亦可為internal。
下例為定義一個(gè)密封類(lèi)。public sealed class MyClass{// Class members.}
下例為使用一個(gè)密封類(lèi)。
public class MyClass : MyBase{// Class members.}
注意,在C#的類(lèi)定義中,只能有一個(gè)基類(lèi)。如果繼承了一個(gè)抽象類(lèi),該派生類(lèi)除非也是抽象的,就必須實(shí)現(xiàn)繼承該抽象類(lèi)的所有抽象成員。編譯器不允許派生類(lèi)訪問(wèn)高于該基類(lèi)的類(lèi)。也就是說(shuō),內(nèi)部類(lèi)可繼承于一個(gè)公共基類(lèi),但公共基類(lèi)不能繼承于一個(gè)內(nèi)部類(lèi)。
在類(lèi)的繼承層次結(jié)構(gòu)中,所有的類(lèi)的根都是System.Object。如果沒(méi)有使用基類(lèi),則所定義的類(lèi)就只繼承于基類(lèi)System.Object。
? 為類(lèi)指定接口。語(yǔ)法:
[public] class MyClass :[ MyBase, ]IMyInterface[, IMySecondInterface][, ...]{// Class members.}
2.3 定義接口、聲明接口的屬性
? public interface 下例:定義一個(gè)接口。
接口修飾符為public或internal;無(wú)abstract和sealed。接口無(wú)根。
[public ]interface IMyInterface{// Interface members.}
? 接口繼承。下例:定義一個(gè)接口,該接口可以繼承于多個(gè)接口。
public interface IMyInterface : IMyBaseInterface, IMyBaseInterface2{// Interface members.}
3、 變量和表達(dá)式
3.1 變量
3.1.1 變量命名要點(diǎn)
(1)必須以字母、下劃線或@開(kāi)頭,其后可為字母、下劃線或數(shù)字。
(2)禁用關(guān)鍵字。
(3)區(qū)分大小寫(xiě)。
(4)流行的匈牙利命名法,不同類(lèi)型前以同一前綴?;蛞宰饔脜^(qū)分作前綴,但不適合協(xié)同編程。
(5)微軟建議對(duì)于簡(jiǎn)單的變量使用camelCase命名法,對(duì)于高級(jí)的使用PascalCase命名法。
3.1.2 聲明變量
? 聲明一個(gè)變量
<type> <name>;
<type>:變量的類(lèi)型(見(jiàn)<type>可選的內(nèi)容和含義);<name>:用戶(hù)定義的變量的名稱(chēng)。
? 聲明多個(gè)變量,用逗號(hào)隔開(kāi)
int xSize, ySize;
3.1.3 為變量賦值
? 為一個(gè)變量賦值
int myInteger;string myString;myInteger = 17;myString = "\"myInteger\" is";
int xSize, ySize = 5;
xSize使用前尚需初始化
? 為多個(gè)變量賦值
int xSize = 4, ySize = 5;
3.1.4 變量的作用域關(guān)鍵字
? 全局變量和局部變量
3.2 字面值
表達(dá)式由運(yùn)算符和操作數(shù)組成。變量和字面值,稱(chēng)為操作數(shù)。運(yùn)算符包括數(shù)學(xué)運(yùn)算法、邏輯運(yùn)算符和賦值運(yùn)算符。運(yùn)算符按照操作數(shù)的數(shù)量又分:
? Unary — Act on single operands 一元運(yùn)算符(一個(gè)操作數(shù))
? Binary — Act on two operands 二元運(yùn)算符(二個(gè)操作數(shù))
? Ternary — Act on three operands 三元運(yùn)算符(三個(gè)操作數(shù))
3.2.1 變量的字面值
? 字面值后綴
許多變量的字面值,在字符后面添加一些后綴,表示類(lèi)型。有些字面值有很多類(lèi)型,由VS編譯時(shí)根據(jù)上下文確定。
TABLE 3-4: Literal ValuesTYPE(S)CATEGORYSUFFIXEXAMPLE/ALLOWED VALUES
bool BooleanNone True or false
int, uint, long, ulong IntegerNone 100
uint, ulongInteger u or U100U
long, ulong Integerl or L100L
ulong Integer ul, uL, Ul, UL, lu, lU,
Lu, or LU100UL
floatReal f or F1.5F
doubleRealNone, d, or D1.5
decimalRealm or M1.5M
charCharacterNone'a', or escape sequence
string String None"a…a", may include escape sequences
? 字符串轉(zhuǎn)義
所謂轉(zhuǎn)義,是將有可能破環(huán)字符串完整性的符號(hào)轉(zhuǎn)換為字符。
字符串是引用類(lèi)型??墒褂棉D(zhuǎn)義序列、雙引號(hào)賦值。也可以被賦予null值。
TABLE 3-5: Escape Sequences for String Literals
ESCAPE SEQUENCE
轉(zhuǎn)義序列
CHARACTER PRODUCED
UNICODE VALUE OF CHARACTER
字符的Unicode值
\' Single quotation mark 單引號(hào)0x0027
\"Double quotation mark雙引號(hào)0x0022
\\ Backslash反斜杠0x005C
\0Null空0x0000
\a Alert (causes a beep)警告(發(fā)出一個(gè)蜂鳴)0x0007
\bBackspace退格0x0008
\f Form feed換頁(yè)0x000C
\nNew line換行0x000A
\rCarriage return回車(chē)0x000D
\tHorizontal tab 水平制表符0x0009
\vVertical tab垂直制表符0x000B
字符串轉(zhuǎn)義舉例:
下列字符串等意:目的是把單引號(hào)看作字符串的一個(gè)字符
"Karli\'s string.""Karli\u0027s string."
使用@符號(hào),可以不使用“轉(zhuǎn)義序列”:
@"Verbatim string literal."
上例避免某位小數(shù)點(diǎn)的影響。下例必須使用@
@"A short list:item 1item 2"
下列字符串等意:
"C:\\Temp\\MyDir\\MyFile.doc"@"C:\Temp\MyDir\MyFile.doc"
3.3 運(yùn)算符
? 簡(jiǎn)單數(shù)學(xué)運(yùn)算符
TABLE 3-6: Simple Mathematical OperatorsOPERATORCATEGORYEXAMPLE EXPRESSION RESULT
+Binaryvar1 = var2 + var3;var1 is assigned the value that is the sum of var2 and var3.
- Binary var1 = var2 - var3;
var1 is assigned the value that is the value of var3 subtracted
from the value of var2.
* Binary var1 = var2 * var3; var1 is assigned the value that is the product of var2 and var3.
/Binary var1 = var2 / var3;var1 is assigned the value that is the result of dividing var2 by var3.
%Binaryvar1 = var2 % var3;
var1 is assigned the value that is the remainder when var2
is divided by var3.
+ Unary var1 = +var2; var1 is assigned the value of var2.
- Unary var1 = -var2; var1 is assigned the value of var2 multiplied by -1.
? char類(lèi)型和string類(lèi)型運(yùn)算符
注意,char類(lèi)型變量的操作數(shù)不能使用上表的簡(jiǎn)單數(shù)學(xué)運(yùn)算符,否則得到的結(jié)果是一個(gè)數(shù)值。
上述+可用于string類(lèi)型的操作數(shù)(如下表)。而其它運(yùn)算符不能用于字符串類(lèi)型的操作數(shù)。
TABLE 3-7. The String Concatenation OperatorOPERATORCATEGORYEXAMPLE EXPRESSIONRESULT
+Binaryvar1 = var2 + var3;
var1 is assigned the value that is the concatenation
of the two strings stored in var2 and var3.
? 加/減運(yùn)算符
TABLE 3-8: Increment and Decrement OperatorsOPERATORCATEGORY EXAMPLE EXPRESSIONRESULT
++Unary var1 = ++var2; var1 is assigned the value of var2 + 1. var2 is incremented by 1.
-- Unaryvar1 = --var2; var1 is assigned the value of var2 - 1. var2 is decremented by 1.
++Unary var1 = var2++; var1 is assigned the value of var2. var2 is incremented by 1.
-- Unary var1 = var2--; var1 is assigned the value of var2. var2 is decremented by 1.
操作數(shù)var2總是加1或減1。符號(hào)在前,結(jié)果等于操作數(shù)加1或減1。符號(hào)在后,結(jié)果等于操作數(shù)。
? 賦值運(yùn)算符
TABLE 3-9: Assignment OperatorsOPERATORCATEGORYEXAMPLE EXPRESSION RESULT
=Binary var1 = var2; var1 is assigned the value of var2.
+= Binaryvar1 += var2;var1 is assigned the value that is the sum of var1 and var2.
-= Binaryvar1 -= var2; var1 is assigned the value that is the value of var2 subtracted from the value of var1.
*=Binaryvar1 *= var2;var1 is assigned the value that is the product of var1 and var2.
/=Binary var1 /= var2;var1 is assigned the value that is the result of dividing var1 by var2.
%=Binary var1 %= var2;var1 is assigned the value that is the remainder when var1 is divided by var2.
注意:與+一樣,+=也可以用于字符串類(lèi)型的操作數(shù)。
? 布爾比較運(yùn)算符
TABLE 4-1: Boolean Comparison OperatorsOPERATORCATEGORYEXPRESSIONRESULT
==Binaryvar1 = var2 == var3;
var1 is assigned the value true if var2 is equal to var3, or
false otherwise.
!=Binaryvar1 = var2 != var3;
var1 is assigned the value true if var2 is not equal to var3,
or false otherwise.
<Binaryvar1 = var2 < var3;
var1 is assigned the value true if var2 is less than var3, or
false otherwise.
>Binaryvar1 = var2 > var3;
var1 is assigned the value true if var2 is greater than var3,
or false otherwise.
<=Binaryvar1 = var2 <= var3;
var1 is assigned the value true if var2 is less than or equal
to var3, or false otherwise.
>=Binaryvar1 = var2 >= var3;
var1 is assigned the value true if var2 is greater than or equal
to var3,or false otherwise.
? 布爾值運(yùn)算符
TABLE 4-2: Boolean Operators for Boolean ValuesOPERATORCATEGORYEXAMPLE EXPRESSIONRESULT
! Unaryvar1 = !var2;
var1 is assigned the value true if var2 is false, or false if var2 is true.
(Logical NOT)
& Binaryvar1 = var2 & var3;
var1 is assigned the value true if var2 and var3 are both true,
or false otherwise.(Logical AND)
| Binaryvar1 = var2 | var3;
var1 is assigned the value true if either var2 or var3 (or both) is
true,or false otherwise.(Logical OR)
∧Binaryvar1 = var2 ∧ var3;
var1 is assigned the value true if either var2 or var3, but not both,
is true, or false otherwise. (Logical XOR or exclusive OR)
? 條件布爾運(yùn)算符
TABLE 4-3: Conditional Boolean OperatorsOPERATORCATEGORYEXAMPLE EXPRESSIONRESULT
&&Binaryvar1 = var2 && var3;
var1 is assigned the value true if var2 and var3 are both true, or
false otherwise.(Logical AND)
|| Binaryvar1 = var2 || var3;
var1 is assigned the value true if either var2 or var3 (or both) is
true, or false otherwise. (Logical OR)
? 布爾賦值運(yùn)算符
TABLE 4-4: Boolean Assignment OperatorsOPERATORCATEGORYEXAMPLE EXPRESSIONRESULT
&=Binaryvar1 &= var2;var1 is assigned the value that is the result of var1 & var2.
|=Binaryvar1 |= var2; var1 is assigned the value that is the result of var1 | var2.
^=Binaryvar1 ^= var2;var1 is assigned the value that is the result of var1 ^ var2.
These work with both Boolean and numeric values in the same way as &, |, and ^.
? 按位運(yùn)算符
TABLE 4-5: Using the & Bitwise OperatorOPERAND 1 BITOPERAND 2 BIT & RESULT BIT
111
100
010
000
TABLE 4-6: Using the | Bitwise OperatorOPERAND 1 BITOPERAND 2 BIT & RESULT BIT
111
101
011
000
TABLE 4-7: Using the ^ Bitwise OperatorOPERAND 1 BITOPERAND 2 BIT & RESULT BIT
110
101
011
000
TABLE 4-8: Using the ~ Bitwise OperatorOPERAND BIT~ RESULT BIT
10
01
C# also allows the use of a unary bitwise operator (~), which acts on its operand by inverting each of its bits,so that the result is a variable having values of 1 for each bit in the operand that is 0, and vice versa. This is shown in Table 4-8.
? 移位運(yùn)算符
TABLE 4-10: Bitwise Shift OperatorsOPERATORCATEGORYEXAMPLE EXPRESSIONRESULT
>>Binaryvar1 = var2 >> var3;
var1 is assigned the value obtained when the binary content of var2
is shifted var3 bits to the right.
<<Binaryvar1 = var2 << var3;
var1 is assigned the value obtained when the binary content of var2
is shifted var3 bits to the left.
? 移位賦值運(yùn)算符
TABLE 4-11: Bitwise Shift Assignment OperatorsOPERATORCATEGORYEXAMPLE EXPRESSIONRESULT
>>=Unaryvar1 >>= var2;
var1 is assigned the value obtained when the binary content of var1 is
shifted var2 bits to the right.
<<=Unaryvar1 <<= var2;
var1 is assigned the value obtained when the binary content of var1 is
shifted var2 bits to the left.
3.4 運(yùn)算符優(yōu)先級(jí)
TABLE 4-12: Operator Precedence (Updated)PRECEDENCEOPERATORS
Highest
++, ?? (used as prefi xes); (), +, – (unary), !, ?
*, /, %
+, –
<<, >>
<, >, <=, >=
==, !=
&
∧
|
&&
||
=, *=, /=, %=, +=, ?=, <<=, >>=, &=, ^=, |=
Lowest++, –– (used as suffi xes)
3.5 數(shù)據(jù)類(lèi)型轉(zhuǎn)換(顯式轉(zhuǎn)換)
語(yǔ)法:
(<destinationType>)<sourceVar>
舉例:
byte destinationVar;short sourceVar = 7;destinationVar = (byte)sourceVar;Console.WriteLine("sourceVar val: {0}", sourceVar);Console.WriteLine("destinationVar val: {0}", destinationVar);
? 使用Convert 命令
TABLE 5-2: Convert CommandsCOMMANDRESULT
Convert.ToBoolean(val)val converted to bool
Convert.ToByte(val) val converted to byte
Convert.ToChar(val) val converted to char
Convert.ToDecimal(val)val converted to decimal
Convert.ToDouble(val) val converted to double
Convert.ToInt16(val)val converted to short
Convert.ToInt32(val) val converted to int
Convert.ToInt64(val) val converted to long
Convert.ToSByte(val) val converted to sbyte
Convert.ToSingle(val) val converted to float
Convert.ToString(val) val converted to string
Convert.ToUInt16(val)val converted to ushort
Convert.ToUInt32(val)val converted to uint
Convert.ToUInt64(val)val converted to ulong
Here, val can be most types of variable (if it’s a type that can’t be handled by these commands, the compiler will tell you).
4 、分支和跳轉(zhuǎn)語(yǔ)句
4.1 跳轉(zhuǎn)語(yǔ)句
?goto 語(yǔ)句
The goto statement is used as follows:
1
goto <labelName>;
Labels are defi ned as follows:
<labelName>:
For example, consider the following:
int myInteger = 5;goto myLabel;myInteger += 10;myLabel:Console.WriteLine("myInteger = {0}", myInteger);
4.2 分支語(yǔ)句
? The ternary operator 三元運(yùn)算符
? The if statement if語(yǔ)句
? The switch statement switch語(yǔ)句
4.2.1 三元運(yùn)算符
常用于簡(jiǎn)單賦值,較復(fù)雜的代碼宜用if語(yǔ)句。
The syntax is asfollows:
1
<test> ? <resultIfTrue>: <resultIfFalse>
Here,<test> is evaluated to obtain a Boolean value, and the result of the operator is either <resultIfTrue> or <resultIfFalse> based on this value.
You might use this as follows to test the value of an int variable called myInteger:
string resultString = (myInteger < 10) ? "Less than 10": "Greater than or equal to 10";
如果myInteger<10,則:resultString = "Less than 10"
如果myInteger≥10,則:resultString = "Greater than or equal to 10"
4.2.2 if語(yǔ)句
The syntax is asfollows:
if (<test>)<code executed if <test> is true>;
if (<test>)<code executed if <test> is true>;else<code executed if <test> is false>;
if (<test>){<code executed if <test> is true>;}else{<code executed if <test> is false>;}
舉例:
static void Main(string[] args){ string comparison; Console.WriteLine("Enter a number:"); double var1 = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Enter another number:"); double var2 = Convert.ToDouble(Console.ReadLine()); if (var1 < var2) comparison = "less than"; else { if (var1 == var2) comparison = "equal to"; else comparison = "greater than"; } Console.WriteLine("The first number is {0} the second number.",comparison); Console.ReadKey();}
舉例:判斷更多的條件:
if (var1 == 1){// Do something.}else{if (var1 == 2){// Do something else.}else{if (var1 == 3 || var1 == 4){// Do something else.}else{// Do something else.}}}
4.2.3 switch語(yǔ)句
標(biāo)準(zhǔn)語(yǔ)法:The basic structure of a switch statement is as follows:
switch (<testVar>){ case <comparisonVal1>: <code to execute if <testVar> == <comparisonVal1> > break; case <comparisonVal2>: <code to execute if <testVar> == <comparisonVal2> > break; ... case <comparisonValN>: <code to execute if <testVar> == <comparisonValN> > break; default: <code to execute if <testVar> != comparisonVals> break;}
使用技巧:
{case <comparisonVal1>: <code to execute if <testVar> == <comparisonVal1> > goto case <comparisonVal2>;case <comparisonVal2>: <code to execute if <testVar> == <comparisonVal2> > break;...
switch (<testVar>){ case <comparisonVal1>: case <comparisonVal2>: <code to execute if <testVar> == <comparisonVal1> or <testVar> == <comparisonVal2> > break; ...
switch (myInteger){ case 1: <code to execute if myInteger == 1> break; case ?1: <code to execute if myInteger == ?1> break; default: <code to execute if myInteger != comparisons> break;}
5、循環(huán)語(yǔ)句
? do循環(huán)
語(yǔ)法:
do{ <code to be looped>} while (<Test>);
舉例:
int i = 1;do{ Console.WriteLine("{0}", i++);} while (i <= 10);
? while循環(huán)
語(yǔ)法:
while (<Test>){ <code to be looped>}
舉例
int i = 1;while (i <= 10){ Console.WriteLine("{0}", i++);}
? for循環(huán)
語(yǔ)法:
for (<initialization>; <condition>; <operation>){ <code to loop>}
舉例:
int i;for (i = 1; i <= 10; ++i){Console.WriteLine("{0}", i);}
? 循環(huán)的中斷語(yǔ)句
? break — Causes the loop to end immediately
? continue — Causes the current loop cycle to end immediately (execution continues with the next loop cycle)
? goto — Allows jumping out of a loop to a labeled position (not recommended if you want your code to be easy to read and understand)
? return — Jumps out of the loop and its containing function (see
? 無(wú)限循環(huán)
舉例:
while (true){ // code in loop}
6、高級(jí)語(yǔ)句
? 用戶(hù)輸入語(yǔ)句
語(yǔ)法:
Console.ReadLine()
? 類(lèi)型轉(zhuǎn)換語(yǔ)句