当前在线人数17640
首页 - 分类讨论区 - 电脑网络 - 窗口里的风景版 -阅读文章
未名交友
[更多]
[更多]
文章阅读:C#.Net Funsdamentals (1)
[同主题阅读] [版面: 窗口里的风景] [作者:cogt] , 2007年01月03日09:30:27
cogt
进入未名形象秀
我的博客
[上篇] [下篇] [同主题上篇] [同主题下篇]

发信人: cogt (苦荆茶), 信区: DotNet
标  题: C#.Net Funsdamentals (1)
发信站: BBS 未名空间站 (Wed Jan  3 09:30:46 2007), 转信

Introduction

C# (pronounced "C sharp") is a simple, modern, object-oriented, and type-
safe programming language. It will immediately be familiar to C and C++
programmers. C# combines the high productivity of Rapid Application
Development (RAD) languages and the raw power of C++.

Visual C# .NET is Microsoft's C# development tool. It includes an
interactive development environment, visual designers for building Windows
and Web applications, a compiler, and a debugger. Visual C# .NET is part of
a suite of products, called Visual Studio .NET, that also includes Visual
Basic .NET, Visual C++ .NET, and the JScript scripting language. All of
these languages provide access to the Microsoft .NET Framework, which
includes a common execution engine and a rich class library. The .NET
Framework defines a "Common Language Specification" (CLS), a sort of lingua
franca that ensures seamless interoperability between CLS-compliant
languages 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 .NET and
Visual C++ .NET. C# itself does not include a class library.

Getting started


The canonical "hello, world" program can be written as follows:

using System;
class Hello
{
  static void Main() {
     Console.WriteLine("hello, world");
  }
}
The source code for a C# program is typically stored in one or more text
files with a file extension of .cs, as in hello.cs. Using the command-line
compiler provided with Visual Studio .NET, such a program can be compiled
with the command-line directive

csc hello.cs
which produces an application named hello.exe. The output produced by this
application when it is run is:

hello, world
Close examination of this program is illuminating:

The using System; directive references a namespace called System that is
provided by the Microsoft .NET Framework class library. This namespace
contains the Console class referred to in the Main method. Namespaces
provide a hierarchical means of organizing the elements of one or more
programs. A "using" directive enables unqualified use of the types that are
members of the namespace. The "hello, world" program uses Console.WriteLine
as shorthand for System.Console.WriteLine.
The Main method is a member of the class Hello. It has the static modifier,
and so it is a method on the class Hello rather than on instances of this
class.
The entry point for an application — the method that is called to begin
execution — is always a static method named Main.
The "hello, world" output is produced using a class library. The language
does not itself provide a class library. Instead, it uses a class library
that is also used by Visual Basic .NET and Visual C++ .NET.
For C and C++ developers, it is interesting to note a few things that do not
appear in the "hello, world" program.

The program does not use a global method for Main. Methods and variables are
not supported at the global level; such elements are always contained
within type declarations (e.g., class and struct declarations).
The program does not use either "::" or "->" operators. The "::" is not an
operator at all, and the "->" operator is used in only a small fraction of
programs — those that employ unsafe code.The separator "." is used in
compound names such as Console.WriteLine.
The program does not contain forward declarations. Forward declarations are
never needed, as declaration order is not significant.
The program does not use #include to import program text. Dependencies among
programs are handled symbolically rather than textually. This approach
eliminates barriers between applications written using multiple languages.
For example, the Console class need not be written in C#.


--

※ 来源:·BBS 未名空间站 mitbbs.com·[FROM: 216.99.]

[上篇] [下篇] [同主题上篇] [同主题下篇]
[转寄] [转贴] [回信给作者] [修改文章] [删除文章] [同主题阅读] [从此处展开] [返回版面] [快速返回] [收藏] [举报]
 
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996