DevoinIT
asked on
Generic List Collection - IHow to add a string to the list
I have created a list collection and I am trying to pass a string back to it. It a data member in a WCF class.
Public List<HumDTO> HumID
{
get;
set;
}
when I get a instance of the class"
QueryDTO aDTO = new QueryDTO
Inside this instance is my list
I am trying to pass some value back into the list:
aDTO .HumID = "W352936514";
and I am getting a error
Cannot implicitly convert type string to System.Collection.Generic. List<>
Please let me know what I am doing wrong.
Public List<HumDTO> HumID
{
get;
set;
}
when I get a instance of the class"
QueryDTO aDTO = new QueryDTO
Inside this instance is my list
I am trying to pass some value back into the list:
aDTO .HumID = "W352936514";
and I am getting a error
Cannot implicitly convert type string to System.Collection.Generic.
Please let me know what I am doing wrong.
ASKER
Basically I have a ID number which was originally set-up as a string, But now we need the HumDTO to accept a list of IDs.
I created a class HumDTO :
[DataContract]
Public class HumDTO
{
[DataMember(IsRequired = true)]
public string HumID
{
get;
set;
}
}
Next I call the class above from another class which is called QueryDTO
[DataMember]
public List<HumDTO> HumaID
{
get;
set:
}
I created a class HumDTO :
[DataContract]
Public class HumDTO
{
[DataMember(IsRequired = true)]
public string HumID
{
get;
set;
}
}
Next I call the class above from another class which is called QueryDTO
[DataMember]
public List<HumDTO> HumaID
{
get;
set:
}
ASKER
I created a test Case and her it is
QueryDTO qDTO = new QueryDTO();
qDTO.Accountnumber = "111111111";
qDTO .HumId = "1253647W";
Cannot implicitly convert type string to System.collection.Generic. List<>
QueryDTO qDTO = new QueryDTO();
qDTO.Accountnumber = "111111111";
qDTO .HumId = "1253647W";
Cannot implicitly convert type string to System.collection.Generic.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will try this and let you know.
ASKER
This worked Excellent. I will post this out there for other.
Your value is of type string
It's a little difficult to understand what you're trying to achieve. Could you tell us a little more about the HumDTO type?