Forum guidelines
  • Home
  • »
  • C# Language
  • »
  • C# Adding a Class To List changes all data previously added
AuthorQuestion
C# Adding a Class To List changes all data previously added
Posted on: 13 Dec 2012
 

C# Adding a Class To A List Of Classes changes all data in previously added Classes.
The new class is added to the list as expected.
But data in every class that has been previously added changes to match the newly added class.

tCardInfo2.Add(new TCardInfoClass(cardType.ToString(),strReqID, true));

public static List<TCardInfoClass> tCardInfo2 = new List<TCardInfoClass>();

public class TCardInfoClass // dragon
    {
       static private string arrayID;
       static private string reqId;
       static private bool visible = false;

      public TCardInfoClass(string ArrayID, string ReqID, bool Visible)
      {
  
     arrayID = ArrayID;
        
reqId = ReqID;
        
visible = Visible;
      
}

    }


AuthorReply
Re: C# Adding a Class To List changes all data previously added
Posted on: 13 Dec 2012  
       private string arrayID;
       private string reqId;
       private bool visible = false;
Removed static works OK now.
Thanks

Employers - Post Free Jobs

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.