.


:




:

































 

 

 

 


UseAttrib, .




[RemarkAttribute(" .",

Supplement = " .",

Priority = 10)] class UseAttrib {

//...

}

Supplement Priority - . , .

: ( , ) , object, , .

C# , , . AttributeUsage, Conditional Obsolete, .

AttributeUsage

, AttributeUsage , . AttributeUsage , , System. AttributeUsageAttribute. :

AttributeUsage(AttributeTargets validOn)

validOn , , AttributeTargets , .

 

 

Assembly

 

Class

 

Constructor

 

Delegate

 

Enum

 

Event

 

Field

 

GenericParameter

 

Interface

 

Method

 

Module

 

Parameter

 

Property

 

ReturnValue

 

Struct

 

. , , , .

AttributeTargets.Field I AttributeTargets.Property

AttributeUsage . AllowMultiple, . , . , Inherited, . , , . AllowMultiple (false), Inherited (true).

AttributeUsage ValidOn. AttributeTargets, , . AttributeTargets.All.

Conditional

Conditional , , . , , # define , . , #if.

Conditional , , System. Diagnostics. ConditionalAttribute. Conditional System. Diagnostics. .

// Conditional.

#define TRIAL

Using System;

Using System.Diagnostics;

class Test {

[Conditional("TRIAL")] void Trial() {

Console.WriteLine(" , " +

" .");

[Conditional("RELEASE")] void Release () {

Console.WriteLine(" .");

}

static void Main() {

Test t = new Test();

t.Trial(); // , // TRIAL t.ReleaseO; // , // RELEASE

}

}





:


: 2016-12-03; !; : 485 |


:

:

,
==> ...

1666 - | 1603 -


© 2015-2024 lektsii.org - -

: 0.046 .