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
Post a Comment