I'm going over some c# tutorial that states the following:
"After it finds the attribute class, the compiler will check whether the attribute is allowed on a class. Then it will check for a constructor that matches the parameters specified in the attribute use. If it finds one, it creates an instance of the object by calling the constructor with the specified values"
The name of this paragraph is "compilation process", and it refers to the way the compiler handles attributes. I'm sorry for the ignorance, but shouldn't instances be created at run time?
Thanks.
Attributes define metadata for classes -- every instance of the class (i.e. object) will share the same attribute values. This metadata is stored alongside the type definition, which is calculated once at compile time from the source files.
Since there are attributes that also affect the compiler, I wouldn't be surprised if the compiler did instantiate them when compiling. So what?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With