I am trying to use something like string lists in C#.
Data format:
FamilyName: Trees
Values: [Banana, Neem, Pappaya, Coconut]
====
FamilyName: Animals
Values: [Cat, Dog, Pig, Tiger Lion]
Code I tried:
[DataContract(Name = "FamilyValuesMap", Namespace = "")]
public class FamilyValuesMap
{
[DataMember(Name = "FamilyName", Order = 1)]
public string FamilyName { get; set; }
[DataMember(Name = "Values", Order = 2)]
public List<string> Values { get; set; }
}
[CollectionDataContract(Name = "FamilyValuesMaps", ItemName = "FamilyValuesMap", Namespace = "")]
public class FamilyValuesMaps : List<FamilyValuesMap>
{
}
In the following code I am trying to push the entries to the FamilyValuesMaps,
var FamilyValuesMaps = new FamilyValuesMaps();
FamilyValuesMaps.Add(new FamilyValuesMap { FamilyName = "Trees", Values = { "Banana", "Neem", "Pappaya", "Coconut" } });
I am not sure where the mess happening and the code not working it is returning the following error.
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147467261
HelpLink: null
InnerException: null
Message: "Object reference not set to an instance of an object."
Source: null
StackTrace: null
TargetSite: null
Any suggestion or ideas would be helpful?
>`
– Panagiotis Kanavos May 29 '18 at 10:36