I am trying to concatenate a list of strings into a single string separated by a comma. Pretty straightforward using string.Join
, the problem I am facing is how can I do this using a property?
public class JsonObject
{
public string EntityID { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string Address3 { get; set; }
public List<string> Category = ??
}
I am trying to get a json object and insert it into a DB. Category is an array which I can handle with List<string>
. How do I concat this list of strings into a single string and then return it to string Category? I assume you would have to use a separate class to handle it but other than that I am not sure how else to go about it.
The Json Object looks like this:
"EntityID":"foo",
"Categories": [ "Category1", "Category2", "Category3"]
It is these Categories(1,2,3) that I want to concatenate into the single string i.e.
public string Category;