[英]ASP.NET Core Web Application: create model class that has default User model as property
[英]How to create generic property in model class using asp.net core
public class A
{
public int Val {get; set;}
public int B {get; set;}
public T C{get; set;} // make generic property
}
如何使用 asp.net 內核在 model class 中創建通用屬性。 在上面的代碼中我想做
“C”屬性作為通用屬性並將該屬性轉換為特定的 class。
在“C”中將是動態屬性。
例子
public Class D
{
public int Value1 {get; set;}
}
public Class E
{
public int Value2 {get; set;}
}
“C”屬性具有 D 或 E
public class A<T>
{
public int A {get; set;}
public int B {get; set;}
public T C {get; set;}
}
並像這樣使用它:
var a = new A<D>()
或者
var a = new A<E>()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.