ふらっとC#,C♯,C#(初心者用) Part25at TECH
ふらっとC#,C♯,C#(初心者用) Part25 - 暇つぶし2ch97:デフォルトの名無しさん
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