码迷,mamicode.com
首页 > Windows程序 > 详细

Easy mistakes in c#

时间:2017-04-15 13:53:42      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:nal   cte   ora   tin   bsp   make   bit   private   instance   

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:

  1. 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.
  2. no access modifier allowed on namespace,but public is implicitly.
  3. internal is default to a class
  4. no access modifier allowed on a interface but public is implicitly.
  5. 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#

标签:nal   cte   ora   tin   bsp   make   bit   private   instance   

原文地址:http://www.cnblogs.com/lwhkdash/p/6713746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!