If you have been exposed to C, or if you are an experienced C
programmer, you might be interested in the main differences between C# and C:
C#与C之间的主要区别是:
1. C# does not usually make use of pointers. You can only increment, or decrement a variable as if it were an actual memory pointer inside a special unsafe block.
C#不经常使用指针。你只能在特殊的非类型安全的代码段中,将一个变量作为一个实际的内存指针做increment和decrement操作。
2. You can declare variables anywhere inside a method you want to; they don’t have to be at the beginning of the method.
你可以在方法中的任何位置声明变量,不一定非得在函数的起始部分声明
3. You don’t have to declare an object before you use it; you can define it just as you need it.
你不必首先在使用之前声明一个对象,在用到的时候再声明
4. C# has a somewhat different definition of the struct types, and does not support the idea of a union at all.
C#在结构的定义上有一些不同,但是根本就不支持联合数据类型
5. C# has enumerated types, which allow a series of named values, such as colors or day names, to be assigned sequential numbers, but the syntax is rather different.
C#有枚举数据类型,可以存放已知的数据类型,如color或者day,但是语法相当不同
6. C# does not have bitfields: variables that take up less than a byte of storage.
C#没有bitfields(变量占据少于1个字节的数据类型)
7. C# does not allow variable length argument lists. You have to define a method for each number and type of argument. However C# allows for the last argument of a function to be a variable parameter array.
C#不支持获取变量字节长度的方法,你只能为每个方法成员或者数据类型定义类似Sizeof的函数,但是C#允许函数的最后一个参数为数组参数。