C#學習筆記1---基礎知識

來源:互聯網
上載者:User

標籤:

1. 成對使用#region 和 #endregion可以在vs環境裡自訂摺疊代碼。

2. C#中聲明變數如下:<type> <name>; 如果使用未聲明的變數,編譯器報錯。

3. C#中預設變數類型:

定點數類型

類型    別名         範圍

sbyte  System.SByte    -128~127

byte    System.Byte     0~255

short   System.Int16    -32768~32767

ushort   System.UInt16   0~65535

int     System.Int32    -2147483648~2147483647

uint     System.UInt32   0~4294967295

long   System.Int64    帶符號64位變數

ulong   System.UInt64    無符號64位變數

簡單類型

char   System.Char      一個Unicode字元 0~65535

bool   System.Boolean   布爾值 true 或 false

string   System.String     一組字串

浮點數類型

float    System.Single

double   System.Double

decimal  System.Decimal

4. C#中逸出字元用 "\"

5. C#輸出列印時候的預留位置 {0}、{1} 依次遞增 Console.WriteLine("{0} {1}.", myString, myInteger);

6. 變數命名規則  變數名第一個字元必須是字母、底線_或者@  其後的字元可以是字母、底線或數字  C#變數名嚴格區分大小寫 保留字(關鍵字)不可以作為變數名。

7. .NET Framework命名空間中兩種命名規範 PascalCase和camelCase。

cameCase風格變數名:age,firstName,timeOut

PascalCase風格變數名:Age,LastName,WinterOfDiscount

 

C#學習筆記1---基礎知識

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.