在C和C++中,很容易就能查看并输出变量的地址.
在C#该如何查看对象的地址,内存如何分配呢?
比如:下面的myPeople和myStudent对象,在执行myPeople = myStudent; 语句前后,他们在系统内存分配是什么样的呢?
谢谢!
class Program {
private static void Main(string[] args) {
People myPeople = new People();
Student myStudent = new Student();
myPeople = myStudent;
Console.ReadLine();
}
} public class People {
int a=1;
public int A{get{return a;} set{a=value;}}
} public class Student : People {
public void GotoSchool()
{
Console.WriteLine("学生需要到学校上学!");
}
} }
在C#该如何查看对象的地址,内存如何分配呢?
比如:下面的myPeople和myStudent对象,在执行myPeople = myStudent; 语句前后,他们在系统内存分配是什么样的呢?
谢谢!
class Program {
private static void Main(string[] args) {
People myPeople = new People();
Student myStudent = new Student();
myPeople = myStudent;
Console.ReadLine();
}
} public class People {
int a=1;
public int A{get{return a;} set{a=value;}}
} public class Student : People {
public void GotoSchool()
{
Console.WriteLine("学生需要到学校上学!");
}
} }
http://topic.csdn.net/u/20090926/23/65cac006-6ba0-4911-89a8-aa23412d0d15.html
!help 随便看http://topic.csdn.net/u/20090825/16/725bc96a-33f9-4c63-85ef-01d22d6c1ed2_4.html
或者使用我在350楼中,提供的编程法//-------------- 内存布局 ----------
// written by 儒道佛 @2009.09
// relation to [email protected]
//----------------------------------