下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、本科畢業(yè)設(shè)計(jì)(論文)外文翻譯譯文:c#基礎(chǔ)介紹出自作者anders hejlsberg and scott wiltamuthc#是一種簡(jiǎn)單,現(xiàn)代,面向?qū)ο蠛皖愋桶踩木幊陶Z(yǔ)言,由c和c+發(fā)展而來(lái)。c#牢固地植根于c和c+語(yǔ)言族譜種,并且會(huì)很快被c和c+程序員所熟悉。c#的目標(biāo)在于把visual basic的高生產(chǎn)力和c+本身的能力結(jié)合起來(lái)。c#作為microsoft visual studio 7.0的一部分提供給用戶。除了c#以外,visual studio還支持visual basic,visual+和描述語(yǔ)言vbscript和jscript.所有這些語(yǔ)言都提供對(duì)microsoft.ne
2、t 平臺(tái)的訪問(wèn)能力,它包括一個(gè)通用的執(zhí)行引擎和一個(gè)豐富的類庫(kù)。microsoft.net平臺(tái)定義了一個(gè)“通用語(yǔ)言子集”(cls),是一種混合語(yǔ)言,它可以增強(qiáng)cls兼容語(yǔ)言和類庫(kù)間的無(wú)縫協(xié)同工作能力。對(duì)于c#開(kāi)發(fā)者,這意味著既是c#是一種新的語(yǔ)言,它已經(jīng)可以對(duì)用老牌工具如visual basic和visual c+使用的豐富類庫(kù)進(jìn)行完全訪問(wèn)。c#子集并沒(méi)有包含一個(gè)類庫(kù)。一個(gè)c#程序由一個(gè)或多個(gè)源文件組成。一個(gè)源文件是一個(gè)統(tǒng)一字符編碼的字符的有序序列。燕文件通常和文件系統(tǒng)種的文件有一一對(duì)應(yīng)關(guān)系,但是這個(gè)對(duì)應(yīng)關(guān)系并不需要。從概念來(lái)講,一個(gè)程序在編譯時(shí)有四步:1. 預(yù)處理,一種文本到文本的轉(zhuǎn)換,這使得
3、可以對(duì)程度需文本進(jìn)行條件飽和和刪除。2. 語(yǔ)法分析,它把輸入字符序列轉(zhuǎn)換為一個(gè)標(biāo)記序列。3. 句法分析,它把標(biāo)記序列轉(zhuǎn)換為可執(zhí)行代碼。c#的詞匯和句子的文法散步在整個(gè)文章中。詞匯文法定義如能把字符組合為形式標(biāo)記:句子的文法定義了如何把標(biāo)記組合為c#程序。文法生成包括無(wú)詞尾符號(hào)和有詞尾符號(hào)。在文法生成當(dāng)中,無(wú)詞尾符號(hào)用意大利體表示,而有詞尾符號(hào)用定寬字體。每一個(gè)吳詞尾符號(hào)定義為一系列產(chǎn)品(production)。這一系列產(chǎn)品的第一行是吳詞尾符號(hào)的名稱,接下來(lái)是一個(gè)冒號(hào)。對(duì)于一個(gè)場(chǎng)頻,每個(gè)連續(xù)的鋸齒狀的行的右手邊同左手邊類似是無(wú)詞尾符號(hào)。c#程序中的生命定義了程序的重要聲明。c#程序用名稱空間來(lái)組
4、織,它可以包含類型聲明和潛逃聲明。類型聲明用來(lái)定義類,結(jié)構(gòu),接口,類的聲明可以包含實(shí)例構(gòu)造函數(shù),析構(gòu)函數(shù),靜態(tài)構(gòu)造函數(shù),常數(shù),域,方法,屬性,時(shí)間,索引,操作符和潛逃類型。一個(gè)聲明在聲明所屬的聲明域定義了一個(gè)名稱。除了重載構(gòu)造函數(shù),方法,索引和操作符名稱,在一個(gè)聲明域種有兩個(gè)或更多介紹有相同名稱成員的聲明時(shí),是錯(cuò)誤的。對(duì)一個(gè)而生命域中,包含有相同名稱的不同種類成員是永遠(yuǎn)不可能的。例如,一個(gè)聲明域種不能包括有相同名稱的域和方法。這里有許多種不同類型的聲明域,如下表示:在所有程序的源文件種,不包括嵌套名稱空間聲明的名稱空間成員聲明都是一個(gè)單獨(dú)的組合聲明域,稱為全局聲明域。在所有程序的源文件種,名稱
5、空間成員聲明和有相同完整正確的名稱空間名稱的名稱空間聲明都是一個(gè)單獨(dú)的組合聲明域。每個(gè)類,結(jié)構(gòu)或接口聲明都會(huì)創(chuàng)建一個(gè)新的聲明域。名稱通過(guò)類成員聲明,結(jié)構(gòu)成員什么或接口成員聲明介紹到這個(gè)聲明域中。除了重載構(gòu)造函數(shù)聲明和靜態(tài)構(gòu)造函數(shù)聲明,一個(gè)類類或結(jié)構(gòu)成員聲明不能引入域類或結(jié)構(gòu)名稱相同的成員。一個(gè)類,節(jié)后或接口允許方法和所以的重載。此外,一個(gè)類聲明的方法,而在他們各自簽名中提供了不同的方法聲明。注意基類不影響類的聲明域。而基本接口不影響一個(gè)接口的聲明域。這樣,一個(gè)派生的類或接口可以用和繼承的成員相同的名稱聲明一個(gè)成員。這樣的一個(gè)成員貝成為隱藏了繼承的成員。每個(gè)枚舉聲明創(chuàng)建一個(gè)新的聲明域。名稱通過(guò)枚
6、舉成員聲明介紹到聲明域中。每個(gè)塊或者轉(zhuǎn)換為局部變量創(chuàng)建一個(gè)分立聲明域。名稱通過(guò)局部變量聲明貝引入到這個(gè)聲明域。如果一個(gè)塊是構(gòu)造函數(shù)或方法聲明的主體,在形參列表中聲明的參數(shù)是這2個(gè)塊的局部變量聲明域的成員。塊的局部變量聲明域包括任何嵌套塊。因而,在一個(gè)嵌套塊中不太可能用域嵌套塊中的局部變量有相同名稱聲明一個(gè)局部變量每個(gè)塊或轉(zhuǎn)換塊為標(biāo)簽創(chuàng)建一個(gè)分立的聲明域。名稱通過(guò)標(biāo)簽聲明貝引入到這個(gè)聲明域,而名稱通過(guò)goto聲明引入到這2個(gè)聲明域。塊的局部變量聲明域包括任何嵌套塊。因而,在一個(gè)嵌套塊中不太可能用域嵌套塊中的標(biāo)簽想同名稱聲明一個(gè)標(biāo)簽。在名稱貝聲明的文本順序通常并不重要。特別是,文本順序?qū)τ诼暶骱褪?/p>
7、用名稱空間,類型,常數(shù),方法,屬性,時(shí)間,索引,操作符,構(gòu)造函數(shù),析構(gòu)函數(shù)和靜態(tài)構(gòu)造函數(shù)來(lái)說(shuō)并不重要。聲明順序在下面的途徑才是重要的:域聲明和局部變量的聲明順序決定了他們的初始化是按聲明順序執(zhí)行。局部變量必須在他們被使用前定義。當(dāng)常數(shù)表達(dá)式數(shù)值貝忽略,枚舉成員的聲明順序是重要的。c#語(yǔ)言的類型被分為三類:數(shù)值類型,引用類型和指針類型。 type: value-type reference-type pointer-type指針類型只能用在不安全代碼。數(shù)值類型與引用類型所不同的是,數(shù)值類型變量直接含有他們的數(shù)據(jù),然而引用類型的變量存儲(chǔ)對(duì)他們的數(shù)據(jù)的引用,就是后面要接受的對(duì)象。獨(dú)語(yǔ)引用類型,可能會(huì)
8、出現(xiàn)兩個(gè)變量引用相同對(duì)象的情況,這樣對(duì)于一個(gè)變量的操作就有可能影響到由其他變量引用的對(duì)象。對(duì)于數(shù)值類型,每個(gè)變量都有他們自己對(duì)數(shù)據(jù)的拷貝,這樣就不能能出現(xiàn)一個(gè)對(duì)變量的操作影響到另外一個(gè)的情況。c#的類型系統(tǒng)是統(tǒng)一的,這樣任何類型的數(shù)據(jù)都可以貝看作對(duì)象。c#中的任何類型都直接或簡(jiǎn)介地從bojiect類類型派生,而object是所有類型的最基本類。引用類型的數(shù)值貝看作通過(guò)對(duì)象,這些對(duì)象通過(guò)把數(shù)值看作類型對(duì)象來(lái)簡(jiǎn)化。數(shù)值類型的數(shù)值通過(guò)包裝和解包裝操作來(lái)貝當(dāng)作對(duì)象。變量代表數(shù)據(jù)的實(shí)際存儲(chǔ)位置。每各變量所能存儲(chǔ)的數(shù)值由它本省的類型決定。c+語(yǔ)言是一種類項(xiàng)安全語(yǔ)言(tsl),而且c+編譯器保證每一個(gè)數(shù)值貝
9、保存在相應(yīng)的變量中。變量的數(shù)值可以通過(guò)賦值或者+或-運(yùn)算符改變。在變量貝賦值以前,變量自身的類型必須貝明確的聲明。變量或者貝初始化的或者未初始化的。一個(gè)初始化的變量在貝定義時(shí)貝賦予了一個(gè)確定的初始值,而未初始化的變量在定義時(shí)并未貝賦予確定的初始值。對(duì)于一個(gè)在程序某處貝認(rèn)為具有確定數(shù)值的iua,必然在指向這一位置的所有可能的執(zhí)行路徑上存在賦值操作。c#語(yǔ)言的大多數(shù)都使得程序員可以制定關(guān)于在程序中定義的實(shí)體的公開(kāi)的消息。例如,一個(gè)類中的一個(gè)方法的可訪問(wèn)性,可以通過(guò)用方法修飾符public,protected,internal和private對(duì)它進(jìn)行修飾來(lái)制定。c#使得程序員可以創(chuàng)造聲明信息的新的種
10、類,來(lái)為各種程序?qū)嶓w指定聲明信息,并且在運(yùn)行時(shí)環(huán)境中找回屬性信息。例如,一個(gè)框架也許定義了一個(gè)helpattribute屬性,它可以被放在例如類和方法的程序元素種類來(lái)提供從程序元素到他們的文檔的映射。聲明信息的新種類通過(guò)屬性類的聲明來(lái)定義,它可能有位置的和名稱的參數(shù)。聲明信息使用屬性來(lái)指定c#程序,并且可以在運(yùn)行是作為屬性實(shí)例來(lái)檢索。原文:c# basic introductionfrom written by anders hejlsberg and scott wiltamuthc# is a simple, modern, object oriented, and type-safe p
11、rogramming language derived from c and c+. c# (pronounced “c sharp”) is firmly planted in the c and c+ family tree of languages, and will immediately be familiar to c and c+ programmers. c# aims to combine the high productivity of visual basic and the raw power of c+.here i will introduce some impor
12、tant serise numbers to explain the c#.c# is provided as a part of microsoft visual studio 7.0. in addition to c#, visual studio supports visual basic, visual c+, and the scripting languages vbscript and jscript. all of these languages provide access to the next generation windows services (nwgs) pla
13、tform, which includes a common execution engine and a rich class library. the .net software development kit defines a common language subset (cls), a sort of lingua franca that ensures seamless interoperability between cls-compliant languages and class libraries. for c# developers, this means that e
14、ven though c# is a new language, it has complete access to the same rich class libraries that are used by seasoned tools such as visual basic and visual c+. c# itself does not include a class library.a c# program consists of one or more source files. a source file is an ordered sequence of unicode c
15、haracters. source files typically have a one-to-one correspondence with files in a file system, but this correspondence is not required by c#.conceptually speaking, a program is compiled using four steps:pre-processing, a text-to-text translation that enables conditional inclusion and exclusion of p
16、rogram text.lexical analysis, which translates a stream of input characters into a stream of tokens. syntactic analysis, which translates the stream of tokens into executable code.lexical and syntactic grammars for c# are interspersed throughout this specification. the lexical grammar defines how ch
17、aracters can be combined to form tokens; the syntactic grammar defines how tokens can be combined to form c# programs.grammar productions include non-terminal symbols and terminal symbols. in grammar productions, non-terminal symbols are shown in italic type, and terminal symbols are shown in a fixe
18、d-width font. each non-terminal is defined by a set of productions. the first line of a set of productions is the name of the non-terminal, followed by a colon. each successive indented line contains the right-hand side for a production that has the non-terminal symbol as the left-hand side.declarat
19、ions in a c# program define the constituent elements of the program. c# programs are organized using namespaces, which can contain type declarations and nested namespace declarations. type declarations are used to define classes, structs, interfaces, enums, and delegates. the kinds of members permit
20、ted in a type declaration depends on the form of the type declaration. for instance, class declarations can contain declarations for instance constructors, destructors, static constructors, constants, fields, methods, properties, events, indexers, operators, and nested types.a declaration defines a
21、name in the declaration space to which the declaration belongs. except for overloaded constructor, method, indexer, and operator names, it is an error to have two or more declarations that introduce members with the same name in a declaration space. it is never possible for a declaration space to co
22、ntain different kinds of members with the same name. for example, a declaration space can never contain a field and a method by the same name.there are several different types of declaration spaces, as described in the following.within all source files of a program, namespace-member-declarations wit
23、h no enclosing namespace-declaration are members of a single combined declaration space called the global declaration space.within all source files of a program, namespace-member-declarations within namespace-declarations that have the same fully qualified namespace name are members of a single comb
24、ined declaration space.each class, struct, or interface declaration creates a new declaration space. names are introduced into this declaration space through class-member-declarations, struct-member-declarations, or interface-member-declarations. except for overloaded constructor declarations and st
25、atic constructor declarations, a class or struct member declaration cannot introduce a member by the same name as the class or struct. a class, struct, or interface permits the declaration of overloaded methods and indexers. a class or struct furthermore permits the declaration of overloaded constru
26、ctors and operators. for instance, a class, struct, or interface may contain multiple method declarations with the same name, provided these method declarations differ in their signature. note that base classes do not contribute to the declaration space of a class, and base interfaces do not contrib
27、ute to the declaration space of an interface. thus, a derived class or interface is allowed to declare a member with the same name as an inherited member. such a member is said to hide the inherited member.each enumeration declaration creates a new declaration space. names are introduced into this d
28、eclaration space through enum-member-declarations.each block or switch-block creates a separate declaration space for local variables. names are introduced into this declaration space through local-variable-declarations. if a block is the body of a constructor or method declaration, the parameters d
29、eclared in the formal-parameter-list are members of the blocks local variable declaration space. the local variable declaration space of a block includes any nested blocks. thus, within a nested block it is not possible to declare a local variable with the same name as a local variable in an enclosi
30、ng block.each block or switch-block creates a separate declaration space for labels. names are introduced into this declaration space through labeled-statements, and the names are referenced through goto-statements. the label declaration space of a block includes any nested blocks. thus, within a ne
31、sted block it is not possible to declare a label with the same name as a label in an enclosing block.the textual order in which names are declared is generally of no significance. in particular, textual order is not significant for the declaration and use of namespaces, types, constants, methods, pr
32、operties, events, indexers, operators, constructors, destructors, and static constructors. declaration order is significant in the following ways:declaration order for field declarations and local variable declarations determines the order in which their initializers (if any) are executed.local vari
33、ables must be defined before they are used.declaration order for enum member declarations is significant when constant-expression values are omitted.the types of the c# language are divided into three categories: value types, reference types, and pointer types.type: value-type reference-type pointer
34、-typepointer types can be used only in unsafe code.value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to their data, the latter known as objects. with reference types, it is possible for
35、two variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable. with value types, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other.c#s type system i
36、s unified such that a value of any type can be treated as an object. every type in c# directly or indirectly derives from the object class type, and object is the ultimate base class of all types. values of reference types are treated as objects simply by viewing the values as type object. values of
37、 value types are treated as objects by performing boxing and unboxing operations .variables represent storage locations. every variable has a type that determines what values can be stored in the variable. c# is a type-safe language, and the c# compiler guarantees that values stored in variables are
38、 always of the appropriate type. the value of a variable can be changed through assignment or through use of the + and - operators.a variable must be definitely assigned before its value can be obtained.as described in the following sections, variables are either initially assigned or initially unassigned. an initially assigned variable has
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024石材石材來(lái)料加工及雕刻藝術(shù)創(chuàng)作合同3篇
- 法律行業(yè)安全管理工作總結(jié)
- IT服務(wù)行業(yè)技術(shù)領(lǐng)域突破
- 二零二五年度房產(chǎn)代理銷售業(yè)務(wù)合同規(guī)范3篇
- 保險(xiǎn)服務(wù)員工作總結(jié)
- 二零二五年度桉樹(shù)種植基地環(huán)境保護(hù)監(jiān)測(cè)合同2篇
- 營(yíng)銷行業(yè)銷售話術(shù)培訓(xùn)總結(jié)
- 醫(yī)藥業(yè)務(wù)員客戶維護(hù)總結(jié)
- 日常食物營(yíng)養(yǎng)表
- 農(nóng)村電子商務(wù)案例3篇
- 2025福建中閩海上風(fēng)電限公司招聘14人高頻重點(diǎn)提升(共500題)附帶答案詳解
- 智能網(wǎng)聯(lián)汽車技術(shù)應(yīng)用專業(yè)國(guó)家技能人才培養(yǎng)工學(xué)一體化課程標(biāo)準(zhǔn)
- 政治-北京市朝陽(yáng)區(qū)2024-2025學(xué)年高三第一學(xué)期期末質(zhì)量檢測(cè)考試試題和答案
- 術(shù)后甲狀旁腺功能減退癥管理專家共識(shí)
- 【7道期末】安徽省安慶市區(qū)2023-2024學(xué)年七年級(jí)上學(xué)期期末道德與法治試題(含解析)
- 基金項(xiàng)目經(jīng)理招聘筆試題與參考答案(某大型集團(tuán)公司)2025年
- 2023-2024學(xué)年浙江省麗水市蓮都區(qū)教科版六年級(jí)上冊(cè)期末考試科學(xué)試卷
- 學(xué)校2024-2025學(xué)年教研工作計(jì)劃
- 北京市矢量地圖-可改顏色
- 2024北京初三(上)期末語(yǔ)文匯編:議論文閱讀
- 安徽省蕪湖市2023-2024學(xué)年高一上學(xué)期期末考試 歷史 含解析
評(píng)論
0/150
提交評(píng)論