c# - How can I better populate two arrays in a class? -
i need populate class of subtopics looks this:
public class subtopic { public int[] subtopicid { get; set; } public string[] description { get; set; } }
so far have following code insert in description not yet subtopicid.
var description = new list<string>(); description.add("afds)."); description.add("afas."); ... ... description.add("aees."); new subtopic { description = description.toarray()}
can think of simple way me populate subtopicid numbers 1,2,3 .. etc , there maybe better way can populate subtopic class. better adding list , converting array?
you use class , array initializers:
var subtopic = new subtopic { subtopicid = new[] { 1, 2, 3 }, description = new[] { "afds).", "afas.", "aees." } };
Comments
Post a Comment