troubleshooting Question

C# Copy Object

Avatar of mcs26
mcs26 asked on
.NET ProgrammingC#Microsoft Development
3 Comments1 Solution574 ViewsLast Modified:
Hi,

I have an object (please see code block below) which I want to make a copy of. However when I make a copy of my object and make a change to one the other object also changes.

I do not want to use serialisation either. Can someone please send me some code.

Thanks for any help,
M

public class OrderBlock
    {
        public string BlockID { get; set; }
        public int NumFails { get; set; }
        public List<Orders> OrderList { get; set; }
        public List<Orders> OrderListFailed { get; set; }
    }

    public class Orders
    {
        public bool Failed { get; set; }
        public string Name { get; set; }
        public string ID { get; set; }
        public string Side { get; set; }
        public double Amount { get; set; }
        public bool GoodOrder { get; set; }
    } 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros