Click to See Complete Forum and Search --> : Variable Suffixes


Grofit
April 16th, 2009, 06:52 AM
Hey,

Ive noticed on my travels that there seem to be alot of variable suffixes that ive never seen before...

an example would be:


Object? var;


Im not sure if Object is of type nullable... but it means that the var could be nullable i think... could be wrong though, ive never had need to use it.

Anyway i was wondering:

1) Is there a list of these suffixes somewhere online and what they do?
2) Specifically what does Object^ var; do?

Any advice would be great!

nelo
April 16th, 2009, 06:58 AM
1) Is there a list of these suffixes somewhere online and what they do?
2) Specifically what does Object^ var; do?

1) - Just lookup (MSDN, google, etc) the specifications for C#2 (which introduced nullable types amongst other things) and C#3 (which introduced implicit local variables declarations amongst many other things)

2) - That looks like C++/CLI syntax. Did you see that in C# code?

Grofit
April 16th, 2009, 07:10 AM
1) - Just lookup (MSDN, google, etc) the specifications for C#2 (which introduced nullable types amongst other things) and C#3 (which introduced implicit local variables declarations amongst many other things)

2) - That looks like C++/CLI syntax. Did you see that in C# code?

Im pretty sure it was in source code, ive not seen once single isntance of it, ive just seen these suffixes dotted around but have never been able to track down a single article about them...

MadHatter
April 16th, 2009, 07:21 AM
the ? after a variable type declares it nullable (for value types, but object is already nullable).

the ^ suffix is a reference type and is used in C++ to differentiate between a managed pointer and a native pointer. http://www.codeproject.com/KB/books/CppCliInActionCh1Ex1.aspx