Inline... Eric -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Ankit Bhurat Sent: Monday, July 12, 2004 10:35 AM To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] Value and Reference Types confusion.
Hi all, These days I am reading about .NET Framework. I came across Value and Reference Types and developed some confusion. Pls clarify : a) One book said that all the objects of type Struct are of value type and all Class Objects are of reference types . The same book said : If cTest is a class then cTest x = new cTest(); cTest y ; both x and y are variables of type reference. <eric> That is correct. </eric> b) the other book said that all variables declared with "new" are reference variable and are allocated memory on managed heap. And value type are allocated memory on stack. <eric> That's incorrect. While in C/C++, "new" means "allocate on the heap", in C#, it just means "get me a new instance of this type". If it's a class, it will be on the heap. If it's a struct, it will be on the stack (or contained inside some other object). </eric> I have no confusion about boxing and unboxing . Since I have read C/C++ , I guess the (b) point is more close to the fact. I am totally confused. Regards, Ankit =================================== This list is hosted by DevelopMentor(r) http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
