THINKING: Metadata • OBSOLETEATTRIBUTE is used to control version code?

xiaoxiao2021-03-05  19

Recently paying attention to metadata. The metadata plays a pivotal role in NET, understanding and mastering the metadata is really not a one-powered matter, and it is estimated that the intermittent time will be introduced for half a year. I will now understand it so that metadata is an explanation of classes and class elements.

Now look at ObsoleTeattribute.

MSDN said, "Mark the programs that are no longer used. Unable to inherit this class." Remarks explain this, "ObsoleTeattribute can be applied to all program elements other than the assembly, module, parameters, or return values. Tags the element as an outdated to notify the user: This element will be removed in the future version of the product."

I read two examples, write one yourself:

Public Class Comtax

Tax rate must be modified from October 1! ")> Protected _rate as double = 0.98

Public Readonly Property Rate () AS DOUBLE

Get

Return_Rate 'When editing the code, the cursor moves at this time that it will be prompted: "_rate" is outdated, "Note:

Tax rate must be modified from October 1! "

END GET

End Property

END CLASS

Public Class TestTax

Shang Sub

Main ()

Dim A as new Comtax

Console.writeLine (a.rate)

End Sub

END CLASS

This is when Ide edit:

When we compile it, compile, but prompts to warning information: When

Tax rate must be modified from October 1! ")> Change to

Tax rate must be modified from October 1! "True)> When compiling. I originally thought that ObsoleTeattribute can be used to control version updates. When I arrived on October 1 _Rate automatic failure trigger program running error, but I can't find a way. Estimate ObsoleTeattribute is only used Control version code, especially when team homework, auditors allow the submitted code to vote, and the function needs to be considered, the ; When severe, .

转载请注明原文地址:https://www.9cbs.com/read-32451.html

New Post(0)