-2

I was wondering if someone could help me. I have 2 classes:

`public class EventPutDto
{
    //public string id { get; set; }
    public string eventGbsCode { get; set; }
    //public string portfolioId { get; set; }
    public string businessUnitId { get; set; }
    public List<Multilingual> multilingual { get; set; }
    public bool supportedInPlatform { get; set; }
    public bool gbsEnabled { get; set; }
    public bool isParticipationEvent { get; set; }
}`

public class Multilingual
{
    public string locale { get; set; }
    public string name { get; set; }
}

I want to add a name and locale to the list property in the eventPutDto class. How do I do it? For example I want to add 3 locales so it should be something like

"en-gb" - "english name",
"it-it" - "italian name",
"es-es" - "spanish name"

I need to know this as I'm trying to post some Json to an endpoint.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
Robert
  • 75
  • 1
  • 7
  • 3
    Have you tried anything? What didn't work? When you did a Google search for something like "add item to list in C#" what did you find and where did you get stuck? – David Apr 12 '19 at 22:04
  • You need to instantiate that multilingual list with "new", then add your items. – LarsTech Apr 12 '19 at 22:05

1 Answers1

0

Looks like what you want is a dictionary.

So, locale should not be of type string, but a Dictionary<string, string>

Read up on them, they are a collection of keys and values.

Dositej
  • 114
  • 5