Click to See Complete Forum and Search --> : What syntactically is going on with [STAThread]?


doug_dyer
March 28th, 2003, 02:01 PM
I know that we are selecting a threading model, but what C# syntax feature is

[object] rettype funcname (args)?

Im learning C# and it bugs me to not know why the compiler likes this.

pareshgh
March 28th, 2003, 02:16 PM
MTA/STA models are the threading models supported by C#. the main is the entry point of the C#.NET exe so it starts in STA mode for instance

you could check
VS.NET help (ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemthreadingapartmentstateclasstopic.htm)

-Paresh

doug_dyer
March 28th, 2003, 02:29 PM
Im not interested in what the STAThread means, but what is going on syntactically.

It looks like an array access prior to a function declaration. Im wondering if a C# person can explain it further.


ie:

[somethinghere] int main(void);

pareshgh
March 28th, 2003, 02:34 PM
its known as attribute which defines the behaviour of that method for example if you make the usercontrol,
and add a property,

private static readonly short nT;
[Category("Static"),Description("Set/Get Total"),Browsable(true)]
public static short TC
{
get { return nT; }
}

[cate...]
are the attributes for the property TC
which will show up in the designer view of the usercontrol property when u drag and drop it.

Paresh