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 By peter uss 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 By peter uss on 13 Dec 2012  
       private string arrayID;
       private string reqId;
       private bool visible = false;
Removed static works OK now.
Thanks

Infragistics jQuery Controls

SPONSORED BY

Spire.Doc - Free .NET Word API
Use Spire.Doc to create, read, write, print, and convert word documents to OpenXML, RTF, TXT, XPS, EPUB, EMF, HTML, Image and PDF.