Shivanand Arur

Shivanand Arur

  • NA
  • 3.6k
  • 1.4m

Structures in C#

Jul 4 2011 3:52 AM

Hello, I am currently learning C# language and i had one simple question in my mind which is really troubling me.... I have defined a structure like given below:

struct MyStruct

{

        int x;

        int y;

        public MyStruct(int x,int y)

        {

                this.x = x;

                this.y = y;

        }

        public structName()

        {

                Console.WriteLine("This is MyStruct");

        }

class MyClass

{

        public static void Main(String []args)

        {

                MyStruct m1 = new MyStruct(10,20);

                m1.structName();

        }

}

So my question here is... Since Structures are value type, all the members in it will be stored on Stack... The object is created in the class (which is a reference type). Now will m1 be created on heap or on stack????

One more question is, What should i do to expertise myself in C# language and how to do it? I am currently doing MCPD course for .Net 3.5 frmwrk which has recently started, so..... How will this certification help me in my career???

M waiting for some replies.... Thanks in advance..

Regards,

Shivanand Arur.


Answers (5)