vendredi 29 août 2014

Constructor on type not found


Vote count:

0




I have the following code that does not work for only one class:



List<T> list = new List<T>();
string line;
string[] lines;

HttpWebResponse resp = (HttpWebResponse)HttpWebRequest.Create(requestURL).GetResponse();

using (var reader = new StreamReader(resp.GetResponseStream()))
{
while ((line = reader.ReadLine()) != null)
{
lines = line.Split(splitParams);
list.Add((T)Activator.CreateInstance(typeof(T), lines));
}
}


The constructor for the class that it does not work for is exactly like the other classes for which it works. The only difference is that this class will be passed 16 arguments instead of 2-5. The constructor looks as such:



public StateLog(string[] line)
{
try
{
SessionID = long.Parse(line[0]);
AgentNumber = int.Parse(line[1]);
StateIndex = int.Parse(line[5]);
....
}
catch (ArgumentNullException anex)
{
....
}
}


Like I said, it works for the other 5 classes that use this, the only difference is the number of inputs.



asked 52 secs ago







Constructor on type not found

Aucun commentaire:

Enregistrer un commentaire