{"action":"opened","issue":{"url":"https://api.github.com/repos/wuqxuan/blog/issues/8","repository_url":"https://api.github.com/repos/wuqxuan/blog","labels_url":"https://api.github.com/repos/wuqxuan/blog/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/wuqxuan/blog/issues/8/comments","events_url":"https://api.github.com/repos/wuqxuan/blog/issues/8/events","html_url":"https://github.com/wuqxuan/blog/issues/8","id":153640884,"number":8,"title":"c#: 静态类和静态成员","user":{"login":"wuqxuan","id":3159199,"avatar_url":"https://avatars.githubusercontent.com/u/3159199?v=3","gravatar_id":"","url":"https://api.github.com/users/wuqxuan","html_url":"https://github.com/wuqxuan","followers_url":"https://api.github.com/users/wuqxuan/followers","following_url":"https://api.github.com/users/wuqxuan/following{/other_user}","gists_url":"https://api.github.com/users/wuqxuan/gists{/gist_id}","starred_url":"https://api.github.com/users/wuqxuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wuqxuan/subscriptions","organizations_url":"https://api.github.com/users/wuqxuan/orgs","repos_url":"https://api.github.com/users/wuqxuan/repos","events_url":"https://api.github.com/users/wuqxuan/events{/privacy}","received_events_url":"https://api.github.com/users/wuqxuan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wuqxuan/blog/labels/Unity&C%23","name":"Unity&C#","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-08T07:09:42Z","updated_at":"2016-05-08T07:09:42Z","closed_at":null,"body":"1. 静态类不能实例化，要使用类名本身访问静态类的成员。  对于只对输入参数进行运算而不获取或设置任何内部实例字段的方法集，静态类可以方便地用作这些方法集的容器。\r\n2. 静态成员    \r\n非静态类可以包含静态的方法、字段、属性或事件。 即使没有创建类的实例，也可以调用该类中的静态成员。 **始终通过类名而不是实例名称访问静态成员**。 无论对一个类创建多少个实例，它的**静态成员**都只有一个副本。 静态方法和属性不能访问其包含类型中的非静态字段和事件，并且不能访问任何对象的实例变量（除非在方法参数中显式传递）。\r\n更常见的做法是声明具有一些静态成员的非静态类，而不是将整个类声明为静态类。\r\n静态字段有两个常见的用法：**一是记录已实例化对象的个数，二是存储必须在所有实例之间共享的值。**\r\n静态方法可以被重载但不能被重写，因为它们属于类，不属于类的任何实例。  \r\n对于只对输入参数进行运算而不获取或设置任何内部实例字段的方法集，静态类可以方便地用作这些方法集的容器。\r\n\r\n[static](https://msdn.microsoft.com/zh-cn/library/98f28cdx.aspx)\r\n[静态类和静态类成员](https://msdn.microsoft.com/zh-cn/library/79b3xss3.aspx)"}}