if (you is CSharpDeveloper) Read(this) //Hidden Features of C#
July 2. 2009
0 Comments
public class CallToAction
{
abstract class CSharpDeveloper { }
class You : CSharpDeveloper { }
string ReadTheContentOf(System.Uri url) { return string.Empty; }
System.Uri URL = new System.Uri("http://stackoverflow.com/questions/9033/hidden-features-of-c");
public CallToAction()
{
var you = new You();
if (you is CSharpDeveloper)
ReadTheContentOf(this.URL).AndLearnTonsOfStuffs();
}
}
public static class MyExtensions
{
public static void AndLearnTonsOfStuffs(this string input) { }
}
”This compiles by the way. It won’t do squat, but it compiles!!“
Go spend half a day or a day and read that post, all the answers, the comments and the links within it. I promised you won’t regret it and you might actually learn a thing or two about C# that you don’t know about. I know I did.
Hint: the URL in the code above is actually clickable if you didn’t notice. Or if you are hyperlink-challenged, you can cut and paste the following URL to your browser:
http://stackoverflow.com/questions/9033/hidden-features-of-c
Enjoy…
