About
In this code snippet, we will take a look at attributes in C#.
Attributes are used to add additional information(metadata) to code. For example, you can use [Serializable] to indicate that a class can be serialized. Or as I will demonstrate in the code example a method can be marked as obsolete and Visual Studio will warn you when you attempt to use the obsolete method.
Note: You can even create your own custom attributes.
Let’s look at the code example below to see how to use attributes.
Code:
[amp-gist id=”34b25e1e7be374674c56fcfeb3984cc0″]
As you can see Visual Studio warns us that the method we are trying to invoke(call) is obsolete and displays the message we typed in earlier.