How C# Differs From C

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#允许函数的最后一个参数为数组参数。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值