c# - what is the use of square bracket "[]" in following syntax -


this question has answer here:

this must basic question after stumbling on internet while, unable understand code below. new c#. use case of [] (square brackets)

class options {     [option('f', "file", required = true,         helptext = "input file processed.")]     public string inputfile { get; set; }      [option('o', "outprefix", required = true,         helptext = "output prefix file.")]     public string outprefix { get; set; }      [option('v', "verbose", defaultvalue = false,         helptext = "prints messages standard output.")]     public bool verbose { get; set; }      [parserstate]     public iparserstate lastparserstate { get; set; }      [helpoption]     public string getusage()     {         return helptext.autobuild(this, (helptext current) => helptext.defaultparsingerrorshandler(this, current));     } } 

these attributes. provide custom metadata members. metadata built assembly, , can fetched (by reflection) other code can use information whatever purpose wants.

in particular case, they're being used provide metadata properties can specified on command line, presumably consumed this library.

if you're new c# might want ignore these while - although depends on kind of development you're doing. code relies heavily on attributes (e.g. mvc) , other code hardly touch it.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -