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

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

ntroduction

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++.

Predefined types

few types

object
The ultimate base type of all other types object o = null;

string
String type; a string is a sequence of Unicode characters string s = "hello";

sbyte
8-bit signed integral type sbyte val = 12;

short
16-bit signed integral type short val = 12;

int
32-bit signed integral type int val = 12;

long
64-bit signed integral type long val1 = 12;
long val2 = 34L;

byte
8-bit unsigned integral type byte val1 = 12;

ushort
16-bit unsigned integral type ushort val1 = 12;

uint
32-bit unsigned integral type uint val1 = 12;
uint val2 = 34U;

ulong
64-bit unsigned integral type ulong val1 = 12;
ulong val2 = 34U;
ulong val3 = 56L;
ulong val4 = 78UL;

float
Single-precision floating point type float val = 1.23F;

double
Double-precision floating point type double val1 = 1.23;
double val2 = 4.56D;

bool
Boolean type; a bool value is either true or false bool val1 = true;
bool val2 = false;

char
Character type; a char value is a Unicode character char val = 'h';

decimal
Precise decimal type with 28 significant digits decimal val = 1.23M;
DESCRIPTION

The predefined reference types are object and string. The type object is the
ultimate base type of all other types. The type string is used to represent
Unicode string values. Values of type string are immutable.

The predefined value types include signed and unsigned integral types,
floating point types, and the types bool, char, and decimal. The signed
integral types are sbyte, short, int, and long; the unsigned integral types
are byte, ushort, uint, and ulong; and the floating point types are float
and double.

The bool type is used to represent Boolean values: values that are either
true or false. The inclusion of bool makes it easier to write self-
documenting code, and also helps eliminate the all-too-common C++ coding
error in which a developer mistakenly uses "=" when "==" should have been
used. In C#, the example

int i = ...;
F(i);
if (i = 0)   // Bug: the test should be (i == 0)
  G();
results in a compile-time error because the expression i = 0 is of type int,
and if statements require an expression of type bool.

The char type is used to represent Unicode characters. A variable of type
char represents a single 16-bit Unicode character.

The decimal type is appropriate for calculations in which rounding errors
caused by floating point representations are unacceptable. Common examples
include financial calculations such as tax computations and currency
conversions. The decimal type provides 28 significant digits.

Each of the predefined types is shorthand for a system-provided type. For
example, the keyword int refers to the struct System.Int32. As a matter of
style, use of the keyword is favored over use of the complete system type
name.

Predefined value types such as int are treated specially in a few ways but
are for the most part treated exactly like other structs. Operator
overloading enables developers to define new struct types that behave much
like the predefined value types. For instance, a Digit struct can support
the same mathematical operations as the predefined integral types, and can
define conversions between Digit and predefined types.

The predefined types employ operator overloading themselves. For example,
the comparison operators == and != have different semantics for different
predefined types:

Two expressions of type int are considered equal if they represent the same
integer value.
Two expressions of type object are considered equal if both refer to the
same object, or if both are null.
Two expressions of type string are considered equal if the string instances
have identical lengths and identical characters in each character position,
or if both are null.



Summary


These will help u understand fundas of c#.net .. will continue






       

--

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

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

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

友情链接


 

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

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