Leo
Leo
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
great. I am glad
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
Are you not clear?
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
okay
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
public struct MyStruct { public int[] Array; public MyClass Class; public MyStruct DeepCopy() { var newStruct = new MyStruct(); newStruct.Array = new int[this.Array.Length]; Array.Copy(this.Array, newStruct.Array, this.Array.Length); // Copy elements // Assuming MyClass has a custom method for deep copying newStruct.Class = this.Class.DeepCopy(); // Implement DeepCopy in MyClass return newStruct; } } public class MyClass { public int Property; // Example property public MyClass DeepCopy() { return new MyClass { Property = this.Property }; // Adjust for your properties } }
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
to achieve a true deep copy,
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
okay, you are right
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
Do you understand?
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
public struct MyStruct { public int[] Array; public MyClass Class; public MyStruct DeepCopy() { var newStruct = this; // Create a copy of the struct newStruct.Array = (int[])this.Array.Clone(); // Deep copy of the array newStruct.Class = (MyClass)this.Class.MemberwiseClone(); // Deep copy of the class return newStruct; } }
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
maybe the correct version is:
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
what is the problem?
90 replies
CC#
Created by ElectricTortoise on 2/3/2025 in #help
✅ Deep copy struct
Can I help you?
90 replies