ふらっとC#,C♯,C#( ..
97:デフォルトの名無しさん
08/03/01 23:20:22
>>94
ちょっと作ってみた
public class MyAttribute : System.Attribute
{
public int IntData { get;set;}
public MyAttribute(int intData) { IntData = intData ; }
};
public class SumpleClass
{
[My(10)]
public int Field = 5 ;
};
void f(){
var tmp = new SumpleClass() ;
var attrs = tmp.GetType().GetField( "Field" ).GetCustomAttributes( false ) ;
for (int i = 0; i < attrs.GetLength(0); ++i)
{
var myattr = attrs[i] as MyAttribute ;
if (myattr == null) continue;
System.Console.WriteLine("{0}", myattr.IntData);
}
}
次ページ最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4437日前に更新/241 KB
担当:undef