1
Reply

Why difference in behaviour of 'new' outside and inside unsafe block?

vikrampschauhan

vikrampschauhan

Dec 12 2004 9:31 PM
1.7k
In C#, for class MyClass, on doing: MyClass myClass=new MyClass(); myClass will hold an address, that was returned by new. But if we have an unsafe block of code, unsafe { MyClass myClass1=new MyClass(); } myClass1 is created as an object on the stack. new merely calls the constructor of MyClass. Am I correct? I believe that class objects created in the unsafe block can only be placed on the stack. Am I correct? (I inferred the above from a code-snippet behaviour, I experienced) Thanks Vikram

Answers (1)
Next Recommended Forum