首页 > 解决方案 > 将项目添加到自定义类列表

问题描述

我想知道是否有人可以帮助我。我有 2 节课:

`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; }
}

我想在 eventPutDto 类的列表属性中添加名称和语言环境。我该怎么做?例如,我想添加 3 个语言环境,所以它应该类似于

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

我需要知道这一点,因为我正在尝试将一些 Json 发布到端点。

标签: c#

解决方案


看起来你想要的是一本字典。

所以,locale不应该是 type string,而是一个Dictionary<string, string>

阅读它们,它们是键和值的集合。


推荐阅读