Attributes are a way to associate information with your C # code.
For example, if you want to make your method a web method, you will use the webmethod attribute
[WebMethod] void myfunction() ...
While working with web services and you want to serialize custom objects, you can apply the serialize attribute
[Serializable] public class MyObject { public int n1 = 0; public String str = null; }
if you want to use user32.dll for some window-related tasks, you can import this function using the dllimport attribute as follows
[DllImport("user32.dll")] extern static void SampleMethod();
For more information you can see MSDN
Haseeb Asif
source share