Hidden Features of C#
-
Hi, this is not a hidden feature. This feature is documented ;)
-
Yes, but no one reads the documentation. After attempting to find something relevent 17 times, we've all given up.
well seriously, you should read this book http://blog.oncode.info/wp-content/uploads/2008/02/rtfm.png[^] perhaps you didn't read well, because after 17 iterations you should have your relevant information, if not, read it 17 times again
-
well seriously, you should read this book http://blog.oncode.info/wp-content/uploads/2008/02/rtfm.png[^] perhaps you didn't read well, because after 17 iterations you should have your relevant information, if not, read it 17 times again
-
GenJerDan wrote:
Ja, und hinterher ein Nasenbär und keiner weiss warum.
oh, der kam unerwartet. aber werde ich mir merken :-D
-
GenJerDan wrote:
Ja, und hinterher ein Nasenbär und keiner weiss warum.
oh, der kam unerwartet. aber werde ich mir merken :-D
-
Hi, this is not a hidden feature. This feature is documented ;)
-
sorry, but if you look at the MSDN C# Reference http://msdn.microsoft.com/en-us/library/618ayhy6.aspx[^] and hit C# Operators you can see them at glance. Looks like there is some RTFM to do :-D
-
I know, actually this is title of stackoverflow topic! There are keywords that are not documented.
SalarSoft wrote:
There are keywords that are not documented.
Tried reading the language specs? That documents them. I had a quick look at the StackOverflow link - if these are hidden features they can't have been looking at anything beyond C# in 5 :laugh: minutes.
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.
-
Hidden Features of C# Personally I like ?? operator and started using it since then:
private IList<Foo> _foo;
public IList<Foo> ListOfFoo
{ get { return _foo ?? (_foo = new List<Foo>()); } }Hidden? You have to be kidding me. Each iteration of C# has been preceeded with a barrage of evangalism and education, and to be unaware of things such as "as" can only mean one has had one's head firmly buried in the sand. readonly? hidden? :doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
Hidden? You have to be kidding me. Each iteration of C# has been preceeded with a barrage of evangalism and education, and to be unaware of things such as "as" can only mean one has had one's head firmly buried in the sand. readonly? hidden? :doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
Actually I just copied the stackoverflow title! have you guys noticed __makeref ? http://stackoverflow.com/questions/9033/hidden-features-of-c/9125#9125[^] more info: http://www.eggheadcafe.com/articles/20030114.asp[^] There are good tricks too. Worth reading that, but should I change this topic title?!
-
Hidden? You have to be kidding me. Each iteration of C# has been preceeded with a barrage of evangalism and education, and to be unaware of things such as "as" can only mean one has had one's head firmly buried in the sand. readonly? hidden? :doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
Actually, it does seem very obscure. Much like this operator I stumbled upon the other day:
int x = 5 + 1;
Much to my surprise, this operator actually performs TWO distinct operations, depending on context!
string x = "5" + "1";
My God! An operator that BOTH adds integers AND concatenates strings. I believe it even works on non integral types. Truly a Jack of all trades! Disclaimer: this post is a joke.
-
Actually, it does seem very obscure. Much like this operator I stumbled upon the other day:
int x = 5 + 1;
Much to my surprise, this operator actually performs TWO distinct operations, depending on context!
string x = "5" + "1";
My God! An operator that BOTH adds integers AND concatenates strings. I believe it even works on non integral types. Truly a Jack of all trades! Disclaimer: this post is a joke.
Do I sense some sarcasm... :)
I wasn't, now I am, then I won't be anymore.
-
Do I sense some sarcasm... :)
I wasn't, now I am, then I won't be anymore.
I hope so! ;)
-
Actually, it does seem very obscure. Much like this operator I stumbled upon the other day:
int x = 5 + 1;
Much to my surprise, this operator actually performs TWO distinct operations, depending on context!
string x = "5" + "1";
My God! An operator that BOTH adds integers AND concatenates strings. I believe it even works on non integral types. Truly a Jack of all trades! Disclaimer: this post is a joke.
It's a good thing it's obscure, because the second use gives a result of 51 when the correct answer is 6. ;)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
-
It's a good thing it's obscure, because the second use gives a result of 51 when the correct answer is 6. ;)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
Chris Meech wrote:
the second use gives a result of 51 when the correct answer is 6
Aw noo! I must go back and correct all teh codez for my area summation algorithm! I don't want my boss to see this mistake... time for an area 51 cover-up.
-
GenJerDan wrote:
Ja, und hinterher ein Nasenbär und keiner weiss warum.
oh, der kam unerwartet. aber werde ich mir merken :-D
-
Hidden Features of C# Personally I like ?? operator and started using it since then:
private IList<Foo> _foo;
public IList<Foo> ListOfFoo
{ get { return _foo ?? (_foo = new List<Foo>()); } } -
SalarSoft wrote:
There are keywords that are not documented.
Tried reading the language specs? That documents them. I had a quick look at the StackOverflow link - if these are hidden features they can't have been looking at anything beyond C# in 5 :laugh: minutes.
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.
Actually,, undocumented keywords do exist in c#. They are undocumented as MS don't want us to use them (e.g. there is a high potential for a visit from the FU Fairy). See http://davesbox.com/archive/2008/12/29/documenting-undocumented-features.aspx[^]
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
Actually,, undocumented keywords do exist in c#. They are undocumented as MS don't want us to use them (e.g. there is a high potential for a visit from the FU Fairy). See http://davesbox.com/archive/2008/12/29/documenting-undocumented-features.aspx[^]
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Keith Barrow wrote:
undocumented keywords
That looks like an oxymoron - but that's a debate about semantics. There are identifiers, such as __reftype, that act as though they are keyword in .Net but are not specified as keywords in the C# language. These are implementation details so may not be 'keywords' in e.g. Mono. I don't know of a better way to describe such identifiers than 'undocumented keywords' but the phrase leaves me with bad taste - rather like beetroot. :)
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.
-
Hidden Features of C# Personally I like ?? operator and started using it since then:
private IList<Foo> _foo;
public IList<Foo> ListOfFoo
{ get { return _foo ?? (_foo = new List<Foo>()); } }I think this is not hidden features .. most of C# developers already know this and this is available everywhere.