I have met a strange thing when I decorate my Main method by a custom Attribute like this:
class Program
{
[Attr]
static void Main(string[] args)
{
Console.WriteLine("Main end..");
Console.Read();
}
}
class AttrAttribute : Attribute
{
public AttrAttribute()
{
Console.WriteLine("Hello world!");
}
}
Then the Console Program does not print anything. But when I debug the program, I find both the constructor of the attribute AttrAttribute and the Main method are indeed executed. Can anyone tell me the why..
And if I comment 'Console.WriteLine("Hello world!");' in the constructor of AttrAttribute, the program print "Main end.."..
Thank you every one. (And sorry for my pool English.)