using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsoleApplication
{
class Program
{
[AttributeUsage(AttributeTargets.Property)]
public class ColumnMappingAttribute : System.Attribute
{
private string _name;
public ColumnMappingAttribute(string name)
{
_name = name;
}
public string Name
{
get { return _name; }
}
}
public class MyClass
{
[ColumnMapping("ItemNbr")]
public int ItemNbr
{
get { return 0; }
}
}
static void Main(string[ args)
{
MyClass myClass = new MyClass();
object[ o = myClass.GetType().GetProperty("ItemNbr").GetCustomAttributes(false);
Console.WriteLine(((ColumnMappingAttribute)o[0]).Name);
Console.Read();
}
}
}