What does this C# attribute mean? I am mostly working with C++, and I do know about the concept of attributes in C#, but not sure about this one: It is in a class. So basically we have a property, and an attribute for it.
[Option("h", "help", HelpText = "Shows this help message")]
public bool Help { get; set; }
Thanks
This is a Command Line Option from one of the Console application libraries that help to parse command line arguments.
It might be from the Command Line Parser tool which has very similar syntax to your example.
Attributes is a way to associate information with your C# code.
For example if you want to make your method a web method , you apply the webmethod attribute
[WebMethod]
void myfunction() ...
While working with web services and you want to serialize the custom objects, you can apply the serialize attribute
[Serializable]
public class MyObject {
public int n1 = 0;
public String str = null;
}
if your want to use the user32.dll for some windows related task , you can import the function using the dllimport attribute as follows
[DllImport("user32.dll")]
extern static void SampleMethod();
For more you can see the MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With