Attributes:
An attribute is a declarative tag that is used to convey information to runtime about the behaviors of various elements like classes, methods, structures, enumerators, assemblies etc. in your program.
Syntax for specifying an attribute is as follows: [Attributes(positional_parameters , name_parameter = value)]
Name of the attribute and its values are specified within the square brackets, before the element to which the attribute is applied.
Positional parameters specify the essential information and the name parameters specify the optional information.
Types of attributes:
The .Net Framework provides two types of attributes:
pre-defined attributes.
custom built attributes.
A few pre-defined attributes with in .Net Framework:
Attribute Usage
Conditional
Obsolete
WebMethod
Serializable
It is possible to customize the attribute using parameters
An attribute is a class that inherits from System.Attribute base class
Obsolete :
It is a predefined attribute, which marks a program entity that should not be used.
It enables you to inform the compiler to discard a particular target element.
For example : when a new method is being used in a class and if you still want to retain the old method in the class, you may mark it as obsolete by displaying a message the new method should be used, instead of the old method.
Syntax for Obsolete :
[Obsolete(message)]
The parameter message, is a string describing the reason why the item is obsolete and what to use instead.
[Obsolete(message, iserror)]
The parameter iserror, is a Boolean value. If its value is true, the compiler should treat the use of the item as an error. Default value is false (compiler generates a warning).
ankpro
ankpro training
Asp.net MVC
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
ArrayList
Strings
String Builder
Structures
Enums
Functions
Classes
Inheritance
Polymorphism
Properties
Indexers
Events
Nested Classes
Delegates
Anonymous methods
Labda expressions
Abstract classes
Exception Handling
Linq
Interfaces
Extension methods
Anonymous types
Generics
Collections
Garbage Collection
Reflection
Attributes
Input and output statements
Type casting
Boxing and Unboxing
Var vs Dynamic vs Object