Click here to Skip to main content
15,886,362 members

Comments by Member 10040991 (Top 11 by date)

Member 10040991 17-Sep-13 7:28am View    
The correct call to the method is:
MoveUiP = (List < unitsinplaydata > )DeepClone(UiP);

I was missing a cast. This works perfectly. There is a split second delay in moving units on the map, but I think it is acceptable.
Member 10040991 17-Sep-13 7:11am View    
OK - I had to add using System.Xml; and a dll reference to the project for System.Runtime.Serialization. Now the compiler error says that serializer.PreserveObjectReferences is read-only and can't be assigned to true. I'm assuming I can remark that line out?
Member 10040991 17-Sep-13 6:57am View    
I'm liking this deep clone serializer, but what is the correct syntax to call it? I'm guessing it would be simply MoveUiP = DeepClone(UiP); ?? I'm assuming I have permission to use it? I've been working with C# for about 6 months now on a full time basis and there is a lot to learn and understand. You guys have been a great help, even though most of this is way over my head. Thanks.
Member 10040991 17-Sep-13 6:42am View    
Like the example I provided above, just 40+ items. No nested classes, just basic variables. I suppose I could try the serializable approach, but wasn't sure the int[] array and bool would translate easily.
Member 10040991 16-Sep-13 20:58pm View    
I reuse MoveUiP and have to clear it out. Did I get the example backwards? As I understand it it cycles thru each element of UiP and adds i to MoveUiP?

I just found this code:

var source = new List<string>();

// populate...

var copy = source.Select(x=>string.Copy(x));

But I need to replace the string.Copy with UnitsInPlayData.Copy and I have nothing written in the UnitsInPlayData for a Copy method. Might I add Icloneable to the class and have a Copy method that returns a memberwise clone?

I'll look at this again tomorrow, its getting late. You have been a lot of help so far, I just don't understand it yet. Thanks for sticking with me.