public void AutoImplementedPropertiesAndStructs() { DemoStruct s = new DemoStruct(12); s.MyProperty = 12; Console.WriteLine(s.MyProperty); }
/// <summary> /// _dos the demo of struct. /// </summary> private void _doDemoOfStruct() { //SEEMS TO BEHAVE VERY MUCH LIKE A CLASS FROM THE 'OUTSIDE' DemoStruct myDemoStruct = new DemoStruct(); myDemoStruct.sample_int = 10; Debug.Log("_doDemoOfStruct() myDemoStruct: " + myDemoStruct); }
public override bool Equals(object obj) { if (obj.GetType() != typeof(DemoStruct)) { return(false); } DemoStruct other = (DemoStruct)obj; return(MyInt32 == other.MyInt32 && MyString == other.MyString); }
/// <summary> /// _dos the demo of struct. /// </summary> private void _doDemoOfStruct() { //SEEMS TO BEHAVE VERY MUCH LIKE A CLASS FROM THE 'OUTSIDE' DemoStruct myDemoStruct = new DemoStruct(1, 1.1f); myDemoStruct.sample_int = 2; _doDemoOfStructWhichPassByValue(myDemoStruct); //changes myDemoStruct.sample_float to 99.99f Debug.Log("_doDemoOfStruct() myDemoStruct: " + myDemoStruct); Debug.Log("_doDemoOfStruct() myDemoStruct.sample_int: " + myDemoStruct.sample_int); Debug.Log("_doDemoOfStruct() myDemoStruct.sample_float: " + myDemoStruct.sample_float); }
/// <summary> /// _dos the demo of struct which pass by value. /// </summary> /// /// NOTE: FYI, if you pass a class instance it is passed by reference /// NOTE: *BUT*, if you pass a struct instance it is passed by value ( a copy ) /// /// <param name='aDemoStruct'> /// A demo struct. /// </param> private void _doDemoOfStructWhichPassByValue (DemoStruct aDemoStruct) { //THIS WILL NOT 'PERMANTELY' AFFECT THE DemoStruct INSTANCE aDemoStruct.sample_float = 2.2f; }
/// <summary> /// _dos the demo of struct. /// </summary> private void _doDemoOfStruct () { //SEEMS TO BEHAVE VERY MUCH LIKE A CLASS FROM THE 'OUTSIDE' DemoStruct myDemoStruct = new DemoStruct (1, 1.1f); myDemoStruct.sample_int = 2; _doDemoOfStructWhichPassByValue (myDemoStruct); //changes myDemoStruct.sample_float to 99.99f Debug.Log ("_doDemoOfStruct() myDemoStruct: " + myDemoStruct); Debug.Log ("_doDemoOfStruct() myDemoStruct.sample_int: " + myDemoStruct.sample_int); Debug.Log ("_doDemoOfStruct() myDemoStruct.sample_float: " + myDemoStruct.sample_float); }
/// <summary> /// _dos the demo of struct. /// </summary> private void _doDemoOfStruct() { //SEEMS TO BEHAVE VERY MUCH LIKE A CLASS FROM THE 'OUTSIDE' DemoStruct myDemoStruct = new DemoStruct (); myDemoStruct.sample_int = 10; Debug.Log ("_doDemoOfStruct() myDemoStruct: " + myDemoStruct); }
/// <summary> /// _dos the demo of struct which pass by value. /// </summary> /// /// NOTE: FYI, if you pass a class instance it is passed by reference /// NOTE: *BUT*, if you pass a struct instance it is passed by value ( a copy ) /// /// <param name='aDemoStruct'> /// A demo struct. /// </param> private void _doDemoOfStructWhichPassByValue(DemoStruct aDemoStruct) { //THIS WILL NOT 'PERMANTELY' AFFECT THE DemoStruct INSTANCE aDemoStruct.sample_float = 2.2f; }