首页 > 代码库 > Easy mistakes in c#
Easy mistakes in c#
ACCESS MODIFIERS
c# has some access modifiers below:
public:class or member can be accessed by no restrictions
private:members can only be accessed within the class itself
internal:class or member can only be accessed within the assembly,not others.
protected:members can only be accessed by derived class(or within the class of course), not others non-derived class.
protected internal: members can only be accessed by derived class, OR, in the same assembly.
NOTE:
- not all access modifiers can be used on class,that‘s why there‘s underline on "class or member" and "members". it‘s nonsense to use private,protected,protected internal on a class. This may make mistake easily.
- no access modifier allowed on namespace,but public is implicitly.
- internal is default to a class
- no access modifier allowed on a interface but public is implicitly.
- private is default to members.
Modifiers and Static
Can not use override,virtual or abstract on a static member, cause these are for instance of inheriting
Size of basic types
type | size(byte) | size(bit) | Range |
char | 2 | 16 | |
char | |||
char | |||
char |
Easy mistakes in c#
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。