An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
According to the documentation:
It's important to note that these Attribute objects are instantiated lazily. That is, they won't be instantiated until you use GetCustomAttribute or GetCustomAttributes. They are also instantiated each time. Calling GetCustomAttributes twice in a row will return two different instances of ObsoleteAttribute.
I tested it with the following code:
class Program
{
[Foo(refresh:true)]
public string Name { get; set; }
static void Main(string[] args)
{
Program program = new Program() { Name = "Timon"};
Attribute attribute = program.GetType().GetProperty("Name").GetCustomAttribute(typeof(Foo));
Console.WriteLine();
}
}
class Foo:Attribute
{
public Foo() { }
private bool refreshD;
public Foo(bool refresh)
{
refreshD = refresh;
}
}
It successfully entered the Attribute.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.