《C#基础介绍外文翻译.doc》由会员分享,可在线阅读,更多相关《C#基础介绍外文翻译.doc(9页珍藏版)》请在三一办公上搜索。
1、本科毕业设计(论文)外文翻译译文:C#基础介绍C#是一种简单,现代,面向对象和类型安全的编程语言,由C和C+发展而来。C#牢固地植根于C和C+语言族谱种,并且会很快被C和C+程序员所熟悉。C#的目标在于把VISUAL BASIC的高生产力和C+本身的能力结合起来。C#作为MICROSOFT Visual Studio 7.0的一部分提供给用户。除了C#以外,Visual Studio还支持Visual Basic,Visual+和描述语言Vbscript和Jscript.所有这些语言都提供对Microsoft.NET 平台的访问能力,它包括一个通用的执行引擎和一个丰富的类库。Microsoft
2、.NET平台定义了一个“通用语言子集”(CLS),是一种混合语言,它可以增强CLS兼容语言和类库间的无缝协同工作能力。对于C#开发者,这意味着既是C#是一种新的语言,它已经可以对用老牌工具如Visual Basic和Visual C+使用的丰富类库进行完全访问。C#子集并没有包含一个类库。一个C#程序由一个或多个源文件组成。一个源文件是一个统一字符编码的字符的有序序列。燕文件通常和文件系统种的文件有一一对应关系,但是这个对应关系并不需要。从概念来讲,一个程序在编译时有四步:1. 预处理,一种文本到文本的转换,这使得可以对程度需文本进行条件饱和和删除。2. 语法分析,它把输入字符序列转换为一个标
3、记序列。3. 句法分析,它把标记序列转换为可执行代码。C#的词汇和句子的文法散步在整个文章中。词汇文法定义如能把字符组合为形式标记:句子的文法定义了如何把标记组合为C#程序。文法生成包括无词尾符号和有词尾符号。在文法生成当中,无词尾符号用意大利体表示,而有词尾符号用定宽字体。每一个吴词尾符号定义为一系列产品(PRODUCTION)。这一系列产品的第一行是吴词尾符号的名称,接下来是一个冒号。对于一个场频,每个连续的锯齿状的行的右手边同左手边类似是无词尾符号。C#程序中的生命定义了程序的重要声明。C#程序用名称空间来组织,它可以包含类型声明和潜逃声明。类型声明用来定义类,结构,接口,类的声明可以包
4、含实例构造函数,析构函数,静态构造函数,常数,域,方法,属性,时间,索引,操作符和潜逃类型。一个声明在声明所属的声明域定义了一个名称。除了重载构造函数,方法,索引和操作符名称,在一个声明域种有两个或更多介绍有相同名称成员的声明时,是错误的。对一个而生命域中,包含有相同名称的不同种类成员是永远不可能的。例如,一个声明域种不能包括有相同名称的域和方法。这里有许多种不同类型的声明域,如下表示:在所有程序的源文件种,不包括嵌套名称空间声明的名称空间成员声明都是一个单独的组合声明域,称为全局声明域。在所有程序的源文件种,名称空间成员声明和有相同完整正确的名称空间名称的名称空间声明都是一个单独的组合声明域
5、。每个类,结构或接口声明都会创建一个新的声明域。名称通过类成员声明,结构成员什么或接口成员声明介绍到这个声明域中。除了重载构造函数声明和静态构造函数声明,一个类类或结构成员声明不能引入域类或结构名称相同的成员。一个类,节后或接口允许方法和所以的重载。此外,一个类声明的方法,而在他们各自签名中提供了不同的方法声明。注意基类不影响类的声明域。而基本接口不影响一个接口的声明域。这样,一个派生的类或接口可以用和继承的成员相同的名称声明一个成员。这样的一个成员贝成为隐藏了继承的成员。每个枚举声明创建一个新的声明域。名称通过枚举成员声明介绍到声明域中。每个块或者转换为局部变量创建一个分立声明域。名称通过局
6、部变量声明贝引入到这个声明域。如果一个块是构造函数或方法声明的主体,在形参列表中声明的参数是这2个块的局部变量声明域的成员。块的局部变量声明域包括任何嵌套块。因而,在一个嵌套块中不太可能用域嵌套块中的局部变量有相同名称声明一个局部变量每个块或转换块为标签创建一个分立的声明域。名称通过标签声明贝引入到这个声明域,而名称通过GOTO声明引入到这2个声明域。块的局部变量声明域包括任何嵌套块。因而,在一个嵌套块中不太可能用域嵌套块中的标签想同名称声明一个标签。在名称贝声明的文本顺序通常并不重要。特别是,文本顺序对于声明和使用名称空间,类型,常数,方法,属性,时间,索引,操作符,构造函数,析构函数和静态
7、构造函数来说并不重要。声明顺序在下面的途径才是重要的:域声明和局部变量的声明顺序决定了他们的初始化是按声明顺序执行。局部变量必须在他们被使用前定义。当常数表达式数值贝忽略,枚举成员的声明顺序是重要的。C#语言的类型被分为三类:数值类型,引用类型和指针类型。 TYPE: VALUE-TYPE REFERENCE-TYPE POINTER-TYPE指针类型只能用在不安全代码。数值类型与引用类型所不同的是,数值类型变量直接含有他们的数据,然而引用类型的变量存储对他们的数据的引用,就是后面要接受的对象。独语引用类型,可能会出现两个变量引用相同对象的情况,这样对于一个变量的操作就有可能影响到由其他变量引
8、用的对象。对于数值类型,每个变量都有他们自己对数据的拷贝,这样就不能能出现一个对变量的操作影响到另外一个的情况。C#的类型系统是统一的,这样任何类型的数据都可以贝看作对象。C#中的任何类型都直接或简介地从BOJIECT类类型派生,而OBJECT是所有类型的最基本类。引用类型的数值贝看作通过对象,这些对象通过把数值看作类型对象来简化。数值类型的数值通过包装和解包装操作来贝当作对象。变量代表数据的实际存储位置。每各变量所能存储的数值由它本省的类型决定。C+语言是一种类项安全语言(TSL),而且C+编译器保证每一个数值贝保存在相应的变量中。变量的数值可以通过赋值或者+或-运算符改变。在变量贝赋值以前
9、,变量自身的类型必须贝明确的声明。变量或者贝初始化的或者未初始化的。一个初始化的变量在贝定义时贝赋予了一个确定的初始值,而未初始化的变量在定义时并未贝赋予确定的初始值。对于一个在程序某处贝认为具有确定数值的IUA,必然在指向这一位置的所有可能的执行路径上存在赋值操作。C#语言的大多数都使得程序员可以制定关于在程序中定义的实体的公开的消息。例如,一个类中的一个方法的可访问性,可以通过用方法修饰符PUBLIC,PROTECTED,INTERNAL和PRIVATE对它进行修饰来制定。C#使得程序员可以创造声明信息的新的种类,来为各种程序实体指定声明信息,并且在运行时环境中找回属性信息。例如,一个框架
10、也许定义了一个HELPATTRIBUTE属性,它可以被放在例如类和方法的程序元素种类来提供从程序元素到他们的文档的映射。声明信息的新种类通过属性类的声明来定义,它可能有位置的和名称的参数。声明信息使用属性来指定C#程序,并且可以在运行是作为属性实例来检索。Visual C#.NET.NET首先是一个开发平台,它定义了一种公用语言子集(Common Language Subsct,CLS),这是一种为符合其规范的语言与类库之间提供无缝集成的混合语。.NET统一了编程类库,提供了对下一代多络通信标准,可扩展标记语言(Extensible Markup Language,XML)的完全支持,使应用程
11、序的开发变得更容易更简单.Microsoft.NET计划还将实现人机交互方面的革命,微软将在其软件中添加手写和语音识别的功能,让人们能够与计算机进行更好的交流,并在此基础上继续扩展功能,增加对各种用户终端的支持能力。最为重要的,.NET将改变因特网的行为方式:软件将变成为服务。与Microsoft的其它产品一样,.NET与Windows平台紧密集成,并且与其它微软产品相比它更进一步:由于其运行库已经与操作系统融合在了一起,从广义上把它称为一个运行库也不为过。简而言之,.NET是一种面向网络、支持各种用户终端的开发平台环境。微软的宏伟目标是让Misrosoft.NET彻底改变软件的开发方式、发行
12、方式、使用方式等等,并且不止是针对微软一家,而是面向所有开发商与运营商!.NET的核心内容之一就是要搭建第三代因特网平台,这个网络平台将解决网站之间的协同合作问题,从而是最大限度地获取信息。在.NET平台上,不同网站之间通过相关的协定联系在一起,网站之间形成自动交流,协同工作,提供最全面的服务。C#既具有C+语言功能强大、灵活,又具有VB的简单易学、高效的优点,利用它可以方便快捷地开发基于文字处理、图开图像、数据库、多媒体、网络的Windows应用程序和Web应用程序,它对于迅速崛起的XML和Web Service也提供了全方位的支持。因此,越来越多的人选择它作为程序设计语言。 可视化编程:用
13、传统程序设计语言设计程序时,都是通过编写程序代码来设计用户界面,在设计过程中看不到界面的实际显示效果,必须编译后运行程序才能观察。如果对界面的效果不满意,还要回到程序中修改。有时候,这种编程-编译-修改的操作可能要反复多次,大大影响了软件开发效率。Microsoft Visual Studio 2005提供了可视化设计工具,把Windows界面设计的复杂性“封装”起来,开发人员不必为界面设计而编写大量程序代码。只需要按设计要求的屏幕布局,用系统提供的工具,在屏幕上画出各种“部件”,即图形对象,并设置这些图形对象的属性。Microsoft Visual Studio 2005自动产生界面设计代码
14、,程序设计人员只需要编写实现程序功能的那部分代码,从而可以大大提高程序设计的效率。 面向对象的程序设计Microsoft Visual Studio 2005支持面向对象的程序设计,但它与一般的面向对象的程序设计语言(C+)不完全相同。在一般的面向对象程序设计语言中,对象由程序代码和数据组成,是抽象的概念;而Microsoft Visual Studio 2005则是应用面向对象的程序设计方法,把程序和数据封装起来作为一个对象,并为每个对象赋予应有的属性,使对象成为实在的东西。在设计对象时,不必编写建立和描述每个对象的程序代码,而是用工具画在界面上,Microsoft Visual Studi
15、o 2005自动生成对象的程序代码并封装起来。每个对象以图形方式显示在界面上,都是可视的。.1.2系统的功能简介本系统主要可以实现以下的管理功能:读者管理、流通管理、图书管理、系统管理等等。(1) 项目规划图书馆管理系统是一个典型的数据库应用程序,由系统管理、读者管理、流通管理、图书管理等模块组成,特规划如下:(2)系统管理模块该模块的主要任务是维护系统的正常运行和安全性设置,包括新图书管理员的添加、修改密码、照片的添加等等。(3)读者管理模块该模块的功能是实现对读者类别的设置、读者档案的管理、借书证挂失与恢复以及过期续证管理。(4)流通管理模块该模块的主要功能是对图书的借阅、归还、逾期清单和
16、过期后罚款的一些管理。(5)图书管理模块该模块的主要功能有:图书类别设置、图书档案管理、出版社管理、图书注销、图书征定、图书验收、图书盘点等对图书的管理。 (6)系统开发的目标图书馆管理系统总的实现目标是:建立以馆藏目录为基础的书目数据库;实现馆内采购、编目、流通、文献检索等信息化管理;建立图书馆动态网站;接入校园网为广大师生及时提供馆内的最新信息。长期的目标还要实现直接浏览电子图书以及馆际间的图书互借等。.欢迎转载,但请保留出处,本文章转自华软源码,原文链接:原文:C# basic introductionFrom written by Anders Hejlsberg and Scott
17、WiltamuthC# is a simple, modern, object oriented, and type-safe programming 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 Visu
18、al Basic and the raw power of C+.Here I will introduce some important 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
19、provide access to the Next Generation Windows Services (NWGS) platform, 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 la
20、nguages and class libraries. For C# developers, this means that even 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 mor
21、e source files. A source file is an ordered sequence of Unicode characters. 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
22、translation that enables conditional inclusion and exclusion of program text.Lexical analysis, which translates a stream of input characters into a stream of tokens. 待添加的隐藏文字内容3Syntactic analysis, which translates the stream of tokens into executable code.Lexical and syntactic grammars for C# are in
23、terspersed throughout this specification. The lexical grammar defines how characters 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-termina
24、l symbols are shown in italic type, and terminal symbols are shown in a fixed-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
25、a production that has the non-terminal symbol as the left-hand side.Declarations 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 cla
26、sses, structs, interfaces, enums, and delegates. The kinds of members permitted 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, proper
27、ties, events, indexers, operators, and nested types.A declaration defines a 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 nam
28、e in a declaration space. It is never possible for a declaration space to contain 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 follo
29、wing.Within all source files of a program, namespace-member-declarations with 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 th
30、at have the same fully qualified namespace name are members of a single combined 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 interfac
31、e-member-declarations. Except for overloaded constructor declarations and static 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.
32、 A class or struct furthermore permits the declaration of overloaded constructors 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 contri
33、bute to the declaration space of a class, and base interfaces do not contribute 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 d
34、eclaration creates a new declaration space. Names are introduced into this declaration 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
35、a block is the body of a constructor or method declaration, the parameters declared 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 d
36、eclare a local variable with the same name as a local variable in an enclosing 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 labe
37、l declaration space of a block includes any nested blocks. Thus, within a nested 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 signific
38、ant for the declaration and use of namespaces, types, constants, methods, properties, 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 deter
39、mines the order in which their initializers (if any) are executed.Local variables 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
40、, reference types, and pointer types.type: value-type reference-type pointer-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
41、data, the latter known as objects. With reference types, it is possible for 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
42、 is not possible for operations on one to affect the other.C#s type system is 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 a
43、re treated as objects simply by viewing the values as type object. Values of 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
44、language, and the C# compiler guarantees that values stored in variables are 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 f
45、ollowing sections, variables are either initially assigned or initially unassigned. An initially assigned variable has a well defined initial value and is always considered definitely assigned. An initially unassigned variable has no initial value. For an initially unassigned variable to be consider
46、ed definitely assigned at a certain location, an assignment to the variable must occur in every possible execution path leading to that location.Much of the C# language enables the programmer to specify declarative information about the entities defined in the program. For example, the accessibility
47、 of a method in a class is specified by decorating it with the method-modifiers public, protected, internal, and private.C# enables programmers to invent new kinds of declarative information, to specify declarative information for various program entities, and to retrieve attribute information in a
48、run-time environment. For instance, a framework might define a HelpAttribute attribute that can be placed on program elements such as classes and methods to provide a mapping from program elements to documentation for them.New kinds of declarative information are defined through the declaration of attribute classes, which may have positional and named parameters. Declarative information is specified a C# program using attributes, and can be retrieved at run-time as attribute instances.