青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++ Programmer's Cookbook

{C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

Namespaces/Identifiers

Namespaces

You should not call classes with the using keyword. Hence, the code in Listing 1.4.2 results in a compilation error because Console is a class:

Listing 1.4.2

// compilation error
using System.Console;

Because the term Console is one of the classes located in the System namespace, you apply it along with its built-in methods. For example, you can write text to the command prompt by using the WriteLine() method of the Console class, as shown in Listing 1.4.3.

Listing 1.4.3

Console.WriteLine("Hello World");

Even though you cannot directly apply the class names along with the using directive, you can create an alias, as shown in Listing 1.4.4:

Listing 1.4.4

using mydotnet = System.Console;

After that, you have to apply the alias name, mydotnet, in your C# program, as shown in Listing 1.4.5:

Listing 1.4.5

mydotnet.WriteLine("Hello C#");

You can, however, completely omit the namespace declaration (with the using keyword) in a C# program. But, as an alternative, you can refer to the namespace name in the beginning of the relevant line of each statement, as shown in Listing 1.4.6:

Listing 1.4.6

System.Console.WriteLine("Welcome to C#");

A list of .NET namespaces is shown in the following table:

System.Collections System.IO
System.Data System.Net
System.Data.OleDb System.Reflection
Stsrem.Data.SqlClient System.Runtime.InteropServices
System.Data.OracleClient System.Runtime.Remoting
System.Diagnostics System.Security
System.Drawing System.Threading
System.Drawing.Drawing2D      System.Web
System.Drawing.Printing System.Xml
System.Windows.Forms

-------------------------------------------------------------------------
 

---------------------------------------------------------------------------
Assembly

An assembly is a file that is automatically generated by the compiler upon successful compilation of every .NET application. It can be either a Dynamic Link Library or an executable file. It is generated only once for an application and upon each subsequent compilation the assembly gets updated. The entire process will run in the background of your application; there is no need for you to learn deeply about assemblies. However, a basic knowledge about this topic will help you to understand the architecture behind a .NET application.

 

An Assembly contains Intermediate Language (IL) code, which is similar to Java byte code. In the .NET language, it consists of metadata. Metadata enumerates the features of every "type" inside the assembly or the binary. In addition to metadata, assemblies also have a special file called Manifest. It contains information about the current version of the assembly and other related information.

In .NET, there are two kinds of assemblies, such as Single file and Multi file. A single file assembly contains all the required information (IL, Metadata, and Manifest) in a single package. The majority of assemblies in .NET are made up of single file assemblies. Multi file assemblies are composed of numerous .NET binaries or modules and are generated for larger applications. One of the assemblies will contain a manifest and others will have IL and Metadata instructions.
-----------------------------------------------------------------------------------------------------------------------------------------------------

 

Identifiers

Identifiers are names given to namespaces, classes, methods, variables, and interfaces. An identifier must be a whole word and start with either a letter or an underscore. It can be any combination of letters, numbers, and underscores. But, it should not start with a number. Prior to .NET, programmers were using Hungarian-notation guidelines for naming identifiers; however, with .NET Microsoft has recommended Pascal and Camel notations for identifiers. They have also suggested using semantics in the identifier name. Another point you should bear in mind is that identifiers should not be the same as a C# keyword as listed in the section "Keywords." For example, the following code is illegal:

// Error. int cannot be used as a variable name as it a keyword
int int = 5;
 

Identifiers in C# are case sensitive. For instance, X is not equal to x. Some programmers use the @ prefix as a first character when declaring identifiers to avoid a clash with a keyword, but it is not a recommended practice. The following names are valid identifiers in C#:

  1. Hello
  2. hello
  3. H_ello
  4. HelloWorld
  5. X
  6. x
Note: In C#, class names can be different from file names.

You should name the variables using the standard DataType prefixes. Also, the first letter after the prefix should be capitalized. Table 1.6.1 shows a list of prefixes for the various .NET DataTypes. You will learn more about DataTypes in Part 3 of C#—Learning with the FAQs.

Table 1.6.1 List of C# Data Types

Data TypePrefixExample
ArrayarrarrNumber
BooleanblnblnSelect
BytebytbytNumber
CharchrchrPick
DateTimedtmdtmPick
DecimaldecdecPoint
DoubledbldblData
IntegerintintVar
LonglnglngMiles
ObjectobjobjVar
ShortshrshrNumber
SinglesngsngNumber
StringstrstrAddress

Interfaces are usually named with an "I" as the first letter. All Windows Forms controls should be named with the special prefixes, as shown in Table 1.6.2. This is to avoid confusion and also to distinguish among other controls in a complex project. As explained above, the first letter after the prefix should be capitalized. Once you master the naming conventions and prefixes, it will be very easy for you to write and debug the code at a later stage.

Table 1.6.2 List of prefixes for Windows Forms controls

Control NamePrefixExample
ButtonbtnbtnSubmit
TextBoxtxttxtFname
CheckBoxchkchkHobbies
RadioButtonradradMale
ImageimgimgIndia
LabellbllblCity
CalendarcalcalDate

It is beyond the scope of this FAQ to cover the prefixes of all the .NET controls. You will find a detailed list of them in the MSDN Library. (Perform a search using the phrase "naming guidelines")

posted on 2005-11-18 12:49 夢在天涯 閱讀(428) 評論(0)  編輯 收藏 引用 所屬分類: C#/.NET

公告

EMail:itech001#126.com

導航

統計

  • 隨筆 - 461
  • 文章 - 4
  • 評論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1811721
  • 排名 - 5

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              欧美日韩亚洲综合一区| 欧美日韩免费| 亚洲二区在线观看| 欧美激情精品久久久久久免费印度 | 欧美日韩蜜桃| 午夜精品久久久久| 欧美一区二区三区免费观看视频| 狠狠色丁香婷婷综合影院| 免费高清在线视频一区·| 美女视频黄 久久| 亚洲一级片在线观看| 篠田优中文在线播放第一区| 亚洲电影免费在线观看| 日韩视频一区二区三区在线播放免费观看| 欧美日韩国产美| 久久精品一区四区| 欧美伦理一区二区| 久久精品女人| 欧美日韩中国免费专区在线看| 欧美中文在线字幕| 欧美激情一区二区三区| 欧美一区二区三区免费观看| 久久综合色播五月| 午夜精品久久久久影视| 鲁大师影院一区二区三区| 午夜日韩在线观看| 欧美精品 日韩| 久久久久在线观看| 国产精品99免视看9| 免费在线观看成人av| 国产精品青草久久久久福利99| 欧美va天堂| 国产亚洲精品aa| 一本色道久久综合狠狠躁篇怎么玩| 一区二区自拍| 午夜视频久久久| 亚洲一区二区高清| 欧美成人一区二区三区在线观看| 久久精品成人| 国产精品一区二区久激情瑜伽| 亚洲国产成人午夜在线一区| 国产日韩欧美综合精品| 在线亚洲成人| 亚洲婷婷综合久久一本伊一区| 久久综合激情| 久久嫩草精品久久久久| 国产模特精品视频久久久久| 99国产欧美久久久精品| 日韩视频一区二区在线观看 | 亚洲欧洲另类国产综合| 亚洲国产成人久久综合一区| 午夜伦理片一区| 亚洲欧美日韩国产一区二区| 欧美无砖砖区免费| 99热免费精品| 亚洲一区二区三区四区中文| 欧美激情视频在线播放| 亚洲激情视频网站| 亚洲日本欧美| 欧美另类极品videosbest最新版本| 欧美成人小视频| 亚洲第一色在线| 麻豆91精品| 亚洲大胆女人| 日韩视频欧美视频| 欧美激情国产日韩| 日韩一区二区精品| 亚洲欧美成人在线| 国产精品久久久免费| 一区二区三区你懂的| 亚洲欧美色婷婷| 国产日韩欧美在线观看| 久久精品亚洲一区| 欧美激情乱人伦| 一本到高清视频免费精品| 欧美日韩一区二区视频在线| 在线视频一区二区| 久久美女性网| 亚洲电影下载| 欧美日本韩国一区| 午夜精品福利在线| 欧美77777| 一区二区免费在线视频| 国产精品亚洲综合| 久久久最新网址| 亚洲精选久久| 久久男女视频| 夜夜嗨av一区二区三区| 国产乱码精品一区二区三区不卡| 久久精品视频免费播放| 亚洲精品视频啊美女在线直播| 午夜精品久久久久久久久| 黄色精品免费| 欧美系列精品| 久久久国产一区二区| 日韩亚洲欧美一区| 久色婷婷小香蕉久久| 国产精品99久久久久久有的能看| 国产视频一区在线观看一区免费| 欧美成人一区二区三区在线观看| 亚洲一区精彩视频| 亚洲国产精品久久久久婷婷老年| 午夜精品福利一区二区三区av| 在线视频国产日韩| 国产精品毛片在线| 欧美激情偷拍| 久久久精品国产免大香伊| 一区二区免费看| 欧美激情国产日韩精品一区18| 欧美主播一区二区三区| 一区二区三区视频在线播放| 狠狠爱综合网| 国产麻豆精品久久一二三| 欧美精品网站| 久久婷婷丁香| 欧美一区影院| 亚洲一区二区三区精品视频| 亚洲日本aⅴ片在线观看香蕉| 久久免费高清视频| 欧美一区二区三区播放老司机| 日韩午夜电影av| 91久久精品日日躁夜夜躁国产| 国产日韩欧美91| 国产精品久99| 欧美视频网址| 欧美三级第一页| 欧美精品久久久久久久久老牛影院| 久久久久高清| 久久午夜羞羞影院免费观看| 午夜一区在线| 性亚洲最疯狂xxxx高清| 亚洲免费在线观看视频| 亚洲一二区在线| 亚洲视频在线观看视频| 亚洲视频高清| 亚洲一区综合| 午夜精品久久久久久久久久久久| 亚洲一区欧美| 亚洲欧美在线x视频| 亚洲欧美在线高清| 欧美一区免费视频| 久久国产一区| 久久久久久一区二区| 裸体素人女欧美日韩| 欧美大片在线观看一区二区| 欧美电影免费观看高清| 欧美激情一区在线观看| 欧美日韩一区高清| 国产精品久久久久一区| 国产精品天美传媒入口| 国产欧美日韩视频一区二区三区| 国产日韩亚洲欧美综合| 激情综合中文娱乐网| 91久久精品日日躁夜夜躁欧美 | 亚洲午夜久久久久久久久电影网| 99国内精品久久久久久久软件| 一本色道久久| 欧美一级欧美一级在线播放| 久久夜色精品| 亚洲国产一区在线观看| 一区二区三区欧美成人| 性欧美xxxx大乳国产app| 久久综合色8888| 欧美日韩视频在线观看一区二区三区 | 免费久久99精品国产自| 欧美日韩久久| 国产亚洲va综合人人澡精品| 亚洲激情不卡| 亚洲男女自偷自拍图片另类| 久久综合久久久| 91久久视频| 亚洲欧美日韩人成在线播放| 免费成人av在线| 国产精品久久久久久超碰| 在线播放一区| 亚洲专区国产精品| 你懂的视频一区二区| 99亚洲一区二区| 久久久噜久噜久久综合| 欧美三级不卡| 亚洲国产精品久久久| 性欧美暴力猛交69hd| 亚洲国产精品电影在线观看| 亚洲欧美视频在线| 欧美日韩国产精品 | 国产欧美欧洲在线观看| 亚洲精品欧美日韩专区| 久久精品国产69国产精品亚洲| 亚洲日本激情| 久久精品视频va| 国产麻豆精品theporn| 日韩午夜三级在线| 久久婷婷综合激情| 在线亚洲伦理| 欧美精品日韩一本| 亚洲国产欧洲综合997久久| 久久美女性网| 欧美在线www| 国产精品日本精品| 亚洲午夜激情网页|