What is: System.Collections.Generic.List`1[System.String]

  • Thread starter Thread starter Al Murphy
  • Start date Start date
A

Al Murphy

Hi everyone,

Can you help me please? My questions is, is it normal to see
"System.Collections.Generic.List`1[System.String]"? Can I get rid of
it in some way?

I wrote the followign code where it is occuring:

**** BEGIN STRANGE CODE ****

public Dictionary<string, object> PostParameters { get; set; }

public AddToDictionary(string job, List<string> taskList)
{

PostParameters.Add("meta_Data1", job);
PostParameters.Add("meta_Data2", taskList );

}

**** END STRANGE CODE ****


When I mouse over this second onject that I add to the dictionary
object during debeugging or view it using fiddler I see that it says
something like:


[1] = {[meta_Data2,
System.Collections.Generic.List`1[System.String]]}


The value under this is perfect but I don't like the
"System.Collections.Generic.List`1[System.String]" bit. It looks a bit
ugly IMHO. The problem only occurs when I add the List<string> object
to the dictionary?

Does anyone know how to make this a bit tidier? I would appreciate
any comments/suggestions ideas or guidance that you may like to share.

Thank you,
Al.
 
You've defined your list as being able to hold only string objects.
When you try to pass something to this list that isn't a string
object, .NET will automatically invoke the .ToString() method on your
non-string object to turn it into a string. The results of this are
different based on what the object originally was. If it was a
number, then ToString will convert it to a string literal of that
number. But, on complex compound objects ToString() will usually
return the spelling of the typedefinition used to create that object.
 
Back
Top