public Item(string name, uint cost, uint idItem, TypeStuff typeStuff) { this._stats = new List<Stats> (); this._name = name; this._cost = cost; this._idItem = idItem; this._typeStuff = typeStuff; }
public static void CopyArray() { bool b1 = TypeStuff.IsValueType <CopyArrayData <UnmanagedData> >(); bool b2 = TypeStuff.IsValueType <CopyArrayDataNoInterface <UnmanagedData> >(); bool b3 = TypeStuff.IsValueType <IBase>(); bool b4 = TypeStuff.IsValueType <List <UnmanagedData> >(); IBase[] sourceArray = new IBase[] { new CopyArrayData <UnmanagedData> { Values = new UnmanagedData[] { new UnmanagedData { }, new UnmanagedData { }, } }, new CopyArrayData <UnmanagedData> { Values = new UnmanagedData[] { new UnmanagedData { }, new UnmanagedData { }, } }, new CopyArrayData <UnmanagedData> { Values = new UnmanagedData[] { new UnmanagedData { }, new UnmanagedData { }, } } }; //var destArray = new IBase[sourceArray.Length]; var destArray = new CopyArrayData <UnmanagedData> [sourceArray.Length]; //Array.Copy(sourceArray, destArray, sourceArray.Length); for (int i = 0; i < sourceArray.Length; i++) { //pool.Values = new UnmanagedData[((CopyArrayData<UnmanagedData>)sourceArray[i]).Values.Length]; //Array.Copy(((CopyArrayData<UnmanagedData>)sourceArray[i]).Values, destArray[i].Values, ((CopyArrayData<UnmanagedData>)sourceArray[i]).Values.Length); destArray[i] = new CopyArrayData <UnmanagedData> { Values = default }; ((CopyArrayData <UnmanagedData>)sourceArray[i]).CopyTo(ref destArray[i]); } ((CopyArrayData <UnmanagedData>)sourceArray[1]).Values[0].x = 13; Console.WriteLine($"Lengths={sourceArray.Length}, {destArray.Length}"); Console.WriteLine("Source Data:"); PrintValues(sourceArray); Console.WriteLine("Copied Data:"); //PrintValues(destArray); }