c# - When is a custom attribute's constructor run? -


When is this going? Does it go for each object that I apply it, or just once? Can it do anything, or restrict its functions?

When did the constructor run? Try it with a sample:

  class program {static or oid key (string [] ARG) {Console.WriteLine ("Creating MyClass Example"); MyClass MC = New MyClass (); Console WrightLine ("Price setting in MyClass instances"); Mc.Value = 1; Console.print line ("attaining properties for myClass type"); Object [] attributes = typef (myclass) .GetCustomAttributes (true); }} AttributeUsage (AttributeTargets.All)] Public Category MyAttribute: Attribution {Public MyAttribute () {Console.WriteLine ("Running Constructor"); }} [MyAttribute] Class MyClass {public int value {get; Set; }}  

And what is the output?

  Creating MyClass Example Setting Value in MyClass Example Running Constructor for MyClass Type Running Constructor  

Then, the Specialty Constructor is run when we type the attribute Begin to test. Note that the attribute is taken in kind, not the type of example.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -