In C#, What is different between local struct instance and member struct instance? -


it simple c# struct example below.

public struct mystruct {     public int a;      public void foo()     {          //do     } }  public class test {     mystruct st;     void dosomething()     {         st.foo();     }     } 

i had known if use struct instance without new, member field must initialized before use. example above don't have error. why?

this has nothing struct.

in c#, every (local) variable has initialized (assigned value) before can use it.

fields of classes initialized default value when instance of class created, don't have assign value explicitly in constructor.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -