MyClass my=new MyClass();
也就是给my.GetType().GetProperties()[0].Attributes赋值public class MyClass
{
  [ColumnAttribute(IsPK=true)]//这样设置了取出的my.GetType().GetProperties()[0].Attributes为None
  public int SID{get;set;}
  
  public string Name{get;set;}
}想问各位大侠,应该怎样给类的属性的Attributes赋值啊?????

解决方案 »

  1.   

    MyClass.SID=0;
    MyClass.Name="";
    这个意思吗?
      

  2.   

    使用my.GetType().GetProperties()[0].GetCustomAttributes()[0]获取自定义特性
      

  3.   

    my.GetType().GetProperties()[0].Attributes取出的值为空?
    在MyClass类的哪个地方设置能让它不为空?
    我目前是这么设置的[ColumnAttribute(IsPK=true)]
    public int SID{get;set;}但是不管用!我就想问到底应该在MyClass这个类里怎么设置,在哪里设置,才能使我的MyClass的对象
    my的my.GetType().GetProperties()[0].Attributes能取道我设置的值???
    my
      

  4.   

    Attribute是类的元数据,这个也能被Set?
    动态添加Attribute倒是做过,Set没有接触过。
      

  5.   

    my.GetType().GetCustomAttributes(typeof(ColumnAttribute), true)[0].