Some Useful C# attributes
| S.No. | Attribute | Description & Usage | ||||
| 1. | Obsolete | Marks a program entity (method, property, field, etc) that should not be used. This is useful to make an old/ unwanted/ outdated method as not usable one without removing or commenting it.
- above code give a warning message during compilation
- above code will give error message with given message |
||||
| 2. | Category | It groups a property under a category in property grid. | ||||
| 3. | Description | It is used to set description to a property
|
||||
| 4. | Conditional | It defines a method whether it will be executed or not when a call.
|
||||
| 5. | DllImport | It is used to import an external dll or API
|
||||
| 6. | CLSComplaint | It is used to tell the compiler to check whether the code is CLSComplaint or not. If it is true the compiler will give warning message for non-CLSComplaint code.
the above attribute’s target is assembly.
the target can be a class or method and before this it is must to set assembly level CLSCompliant attribute. |
Advertisement
Categories: .NET, C#
attribute, CLS complaint, CLScompliant, Conditional Attribute, Obsolete, Property Category, Property Description



Recent Comments