c# - 将项目添加到自定义类列表
问题描述
我想知道是否有人可以帮助我。我有 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 发布到端点。
解决方案
看起来你想要的是一本字典。
所以,locale
不应该是 type string
,而是一个Dictionary<string, string>
阅读它们,它们是键和值的集合。
推荐阅读
- java - java - 如何使用用于CRUD方法的mongodb java驱动程序修复Java中的“MongoClient方法未定义”错误
- javascript - 如何使用反应将元素滚动到视图中?
- javascript - Javascript regexp 组信息有时可能会丢失
- c++ - C++ 中的内存对齐语法
- php - 我的表单在 Laravel 中未正确提交
- excel - 即使在命令行输入密码后,仍然提示输入密码
- rust - 如何在 Rust 中缺少 Copy 的借用元素向量上计算算术运算?
- google-analytics - 如何在谷歌分析中获取帖子网址
- kotlin - Ktor 提示来自基本身份验证块内的路由拦截器内的凭据
- reactjs - 受控的单选按钮警告使用 formik 字段处理它的值