【发布时间】:2022-01-20 03:07:23
【问题描述】:
我正在尝试根据类的枚举属性在类中动态创建属性。
例如,我有一类会议,它有一个位置枚举,如果选择一个位置,则位置详细信息应该不同,例如,如果选择 Inperson,则位置详细信息应该是地址类型的类,否则如果位置选择缩放的细节应该只是一个带有 url 的字符串
public enum Meeting_Location
{
InPerson,
Zoom,
GoogleMeet
}
public class Meeting
{
public string Name;
public Meeting_Location Location;
public ... Location_Details; --> this is dynamic depending on the enum that is selected
}
public class Address
{
public string postcode;
public string country;
public string StreetName;
....
}
【问题讨论】:
-
具有派生特定类的基本位置类型?
-
那么如果在这种情况下选择
Zoom会发生什么Location_Details以及在GoogleMeet的情况下会是什么Location_Details?
标签: c# .net asp.net-core .net-core