DISQUS

Andrey Shchekin's Blog: Simple typeswitch in C# 3.0, Part 2: The Solutions

  • Andrey Titov · 2 years ago
    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;
  • Andrey Shchekin · 2 years ago
    Yes, I have seen a post on a similar problem with LINQ.
    Type inference has its limits.
  • Nina · 2 years ago
    3 comments
  • Clarityx · 8 months ago
    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