/*全部变量--static变量
* 不用new一个对象,就能直接用类名调用的方法:static方法
* (static方法其实就是普通函数)
* 在static方法中,可以调用其它static成员,但不能调用非static成员
* 在非static方法中,可以调用static成员(因为static是全局的)
* 静态类:不能new的类,不能生成对象实例,一般用来实现函数库 Helper, SqlHelper```*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
// Person p = new Person();
// p.Dayin();
Person.Dayin(); //可以直接用类名调用静态方法
Console.ReadKey();
}
}
class Person
{
public int age;//默认值为0
public static void Dayin()
{
Console.WriteLine("{0}",age); //报错 静态函数只能调用静态成员
}
}
}