如何泛型类型属性

本文关键字:属性 泛型类型 | 更新日期: 2023-09-27 18:18:06

有没有一种类似enum的类型可以让我把这些变量合并成一个

    private string StringPropertie;
    private int IntPropertie;
    private float floatPropertie;
    private DateTime DatetimePropertie;
    private bool boolPropertie;

to something has follow.

private enumtype property

如何泛型类型属性

可以使用结构

public struct MyStruct
    {
        public string StringPropertie;
        public int IntPropertie;
        public float floatPropertie;
        public DateTime DatetimePropertie;
        public bool boolPropertie;
    }
    public class MyClass
    {
        public MyClass()
        {
              MyStruct property ;
              //...

              string str = property.StringPropertie;
        }
   }