AccessViolationException:在试图读写受保护内存时引发异常
方法:Equals:确定指定的对象实例是否相等
class Program
{
static void Main(string[] args)
{
Student student = new Student();
bool a = System.AccessViolationException.Equals(student.name, student.gender);//由于Equals返回的值是布尔值,所以声明变量的类型为布尔类型
Console.WriteLine(a);
}
}
class Student
{
public string name;
public int age;
public int Id;
public string gender;
}
运行结果为True