.NET中的类和对象是什么? [英] What is Class and Objects in .NET?
问题描述
大家好,
我无法获得有关DOT NET框架中的类和对象的明确答案.我需要一个实用的答案,请告诉我所有又一件事,引用和对象之间的关系是什么?以下代码行是我对所有这些事情的怀疑.
班级学生
{
//成员和字段
学生st1 =新学生();
}
st1是学生还是学生?如果st1是学生班级的对象,学生班级的参考在哪里?还有一个存储在堆内存中?请告诉我一个切合实际的答案.
谢谢与问候
S.Arun Kumar
Hi All,
I can''t get clear answer about classes and objects in DOT NET framework.I need a practical answer please tell me all and one more thing what is the relationship between reference and objects? The following line of code is my doubt for all those things.
class student
{
//Members and Fields
student st1=new student();
}
Here which one is object st1 or student?If st1 is the object of student class,where is the reference of student class? and one more which one stored in heap memory? Please tell me a practical oriented answer.
Thanks & Regards
S.Arun Kumar
推荐答案
这是对象st1还是学生?
Here which one is object st1 or student?
该对象位于(堆)内存中.您所拥有的只是一个引用,即st1
(有了这样的引用,您就可以访问所有对象成员).
The object is in (heap) memory. All you have of it is a reference, namely st1
(with such reference you gain access to all object members).
如果st1是学生类的对象,那么学生类的引用在哪里?还有哪一个存储在堆内存中?
If st1 is the object of student class,where is the reference of student class? and one more which one stored in heap memory?
student
是类(即对象的类型).
st1
是对该对象的引用.
对象本身(即类实例)位于堆中.
:)
student
is the class (i.e. the type of the object).
st1
is a reference to the object.
The object itself (i.e. the class instance) is in the heap.
:)
此处 [
Here[^] is a very useful document that should help you understand it better.
这篇关于.NET中的类和对象是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!