Hello, I read that C# allow 2 types: value and reference. Class object are always reference types; "struct" and base type (int, float, bool) are value types; but I read that if I embed any value types in a reference type (eg an int32 inside a class declaration), all goes on the heap (even the int32); outside of an object that int32 should go on the stack (the variable with its value).
Above I see 'm' and 'addr' be value types: it should be on the stack. But reading better I can see that they're inside the class 'Program'; I think that Someone create an instance of class 'Program' (I don't know who and where); but the question is: in the manner of C#, every type is inside a Class declaration; so everything goes on the heap; but I know that it isn't possible; then, what happen exactly??? I hope you understand...Code:
class Program { struct Address { public Address (string v, int n) { this.street = v; this.number = n; } internal string street; internal int number; }; Address addr = new Address ("donner",99); public Int32 m = 9; static void Main(string[] args) { System.Int32 i = 99; } }
thanks..