1:
静态成员(静态字段)--->通过类名访问;
实例成员(实例字段)--->通过实例对象访问;
2:
静态方法--->只操作静态字段;
实例方法--->静态实例都可操作;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
public class Cat
{
string name;
string sex;
public static int age;
public static int count;
public Cat()
{
count++;
}
static Cat() {
count++;
}
public Cat(int age)
{
count++;
}
}
class Program
{
static void Main(string[] args)
{
Cat cat1 = new Cat();
Cat cat2 = new Cat(18);
Console.WriteLine("猫的个数:{0}", Cat.count);
Console.Read();
}
}
}
学习真快乐·································