A Repasky

A Repasky

  • NA
  • 231
  • 183.7k

How do you pass List as argument?

Jan 6 2012 9:56 AM
How do you pass List<T> as argument when the T is a class without nameing a class?

Here is what I have:

How do you pass List<T> as argument?

   class ProcessClaims
   {
      public static List<MMORecord> listDataMMO = new List<MMORecord>();
      public static List<PHCSRecord> listDataPHCS = new List<PHCSRecord>();
      public static List<PHCRecord> listDataPHC = new List<PHCRecord>();
      public static List<MMORecord> listDataPHS = new List<MMORecord>();
      public static List<MMORecord> listDataGLB = new List<MMORecord>();
      public static List<PHCRecord> listDataNotcovered = new List<PHCRecord>();
      public static List<MMORecord> listDataDEL = new List<MMORecord>();
      public static List<PHCRecord> listDataMC1 = new List<PHCRecord>();
      public static List<MMORecord> listDataHC = new List<MMORecord>();
      public static List<PHCSRecord> listDataMultiplan = new List<PHCSRecord>();




The MMORecord, PHCSRecord, PHCRecord are classes.


Then I use it to pass to a Method.


      CreateExcelXML.CreateNewSheet(@"E:\MMOExtract\Extract\" + sFilename + Program.extractEndDate + ".xlsx",
         sheet, sheetNum, header, ProcessClaims.listDataPHCS, setNumber);


Here is the Method.


      public static void CreateNewSheet(string path, string sheetName, UInt32Value sheetNum,
         List<string> header, List<PHCSRecord> listData, List<int> setNumber)



How can I pass this List<T> so I do not have to have a Method for each List<T>? I have 10 List's so I

would have to have 10 Methods. Then this goes to another Method and I will have to have 10 more Methods.

It will all be duplicate code except for the List<T> which references a class.


How can I do this so I can only have one general Method for all 10? It is passed as a reference, correct?

Thanks for the help ahead of time. I am still learning C# and .NET.


Arep








Answers (14)