C 學習筆記1 基本語法

2021-08-13 03:26:36 字數 2200 閱讀 8298

在 c# 中,有些識別符號在**的上下文中有特殊的意義,如 get 和 set,這些被稱為上下文關鍵字(contextual keywords)。

下表列出了 c# 中的保留關鍵字(reserved keywords)和上下文關鍵字(contextual keywords):

保留關鍵字

abstract

asbase

bool

break

byte

case

catch

char

checked

class

const

continue

decimal

default

delegate

dodouble

else

enum

event

explicit

extern

false

finally

fixed

float

forforeach

goto

ifimplicit

inin (generic

modifier)

intinte***ce

internal

islock

long

namespace

newnull

object

operator

outout

(generic

modifier)

override

params

private

protected

public

readonly

refreturn

sbyte

sealed

short

sizeof

stackalloc

static

string

struct

switch

this

throw

true

trytypeof

uint

ulong

unchecked

unsafe

ushort

using

virtual

void

volatile

while

上下文關鍵字

addalias

ascending

descending

dynamic

from

getglobal

group

into

join

letorderby

partial

(type)

partial

(method)

remove

select

set

在任何 c# 程式中的第一條語句都是:

using

system

;

using關鍵字用於在程式中包含命名空間。乙個程式可以包含多個 using 語句。

class關鍵字用於宣告乙個類。

注釋是用於解釋**。編譯器會忽略注釋的條目。在 c# 程式中,多行注釋以 /* 開始,並以字元 */ 終止,如下所示:

/* this program demonstrates

the basic syntax of c# programming

language */

單行注釋是用 '//' 符號表示。例如:

}

//end class rectangle

變數是類的屬性或資料成員,用於儲存資料。在上面的程式中,rectangle 類有兩個成員變數,名為 length 和 width。

函式是一系列執行指定任務的語句。類的成員函式是在類內宣告的。我們舉例的類 rectangle 包含了三個成員函式:acceptdetails、getarea 和 display。

在上面的程式中,類 executerectangle 是乙個包含 main() 方法和例項化 rectangle 類的類。

識別符號是用來識別類、變數、函式或任何其它使用者定義的專案。在 c# 中,類的命名必須遵循如下基本規則:

C 學習筆記(1)基本語法

1.簡介 優點 缺點 2.程式結構 注意點 3.基本語法 4.資料型別 引用型別 不包含儲存再變數中的實際資料,但包含對變數的引用,指的是乙個記憶體位置 動態型別 與物件型別相似,型別檢查在執行時發生 字串型別 system.string 類的別名,從object類派生。使用者引用型別 class ...

jQuery學習筆記(1) 基本語法

jquery核心功能是從html頁面裡獲取元素並對其進行操作。其原理和css很相似,通過元素的特性或元素在文件樹 dom tree 中的位置去描述元素組。為了使設計和內容分離,web技術引入了css,而css用到的方法就是選擇器簡明地表現元素。同樣為了將行為和內容分離,我們也可以採用類似的方法,那就...

SQLServer學習筆記(1)基本語法

dml語句 ddl語句 select語句 select 列名稱 from 表名稱 select from 表名稱 是選取所有列的快捷方式 示例 select lastname,firstname from persons select distinct 列名稱 from 表名稱 用於返回唯一不同的值...