DISQUS

DISQUS Hello! Andrey Shchekin's Blog is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

Simple typeswitch in C# 3.0, Part 2: The Solutions

Started by Andrey Shchekin · 10 months ago

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpc ... Continue reading »

4 comments

  • Would your switch get confused if it cannot infer the return type from the first case?

    string result = Switch.Type(document)
    .Case((XsltDocument d) => null)
    .Case((XmlDocument d) => “Xml”)
    .Otherwise(d => “Not Xml and not Xslt”)
    .Result;
  • Yes, I have seen a post on a similar problem with LINQ.
    Type inference has its limits.
  • 3 comments
  • Interesting post. Appreciate it as I have seen something new now.
    Can I use this info on my blog using the direct link to your blog? Thanks in advance

Add New Comment

Returning? Login