Converting the Select Case with To and Is to c# problems

I am convertng to c# 2010 as my job, and none of the automatic tools I have can succeed completely. In special example, this case:

'searchString is a string paramter from a long method
Select Case searchString
   Case "paid"
      'Do something long here
   Case "oaaaaa" To "ozzzzzz", "maaaaaa" To "mzzzzzz"
      'Do other long code
   Case Else
      'other long code
End Select

I am mostly java developer before this, so not great with c# and none with I do not understand the "oaaaa to ...." part and this part is not converting. Can you please point me to right place to find the c# version of this?


There isn't a direct equivalent in C# but you can easily achieve the same semantics (with more readable code!) using the following:

if(searchString == "paid") {
    // do something here
else if(
    searchString.IsInRange("oaaaaa", "ozzzzzz") ||
    searchString.IsInRange("maaaaa", "mzzzzzz")
) {
    // do other long code
else {
    // other long code

public static class StringExtensions {
    public static bool IsInRange(this string s, string lower, string upper) {
    if(String.Compare(lower, upper) > 0) {
        throw new InvalidOperationException();
    return String.Compare(s, lower) >= 0 && String.Compare(s, upper) <= 0

Need Your Help

Is there a way of adding a LOT of Facebook like buttons to a page?

javascript facebook facebook-like

I've tried using the standard Facebook like button. I require about 50 like buttons (that number may grow) on my page. The problem is that the second I add more than a few, it drastically slows dow...

Adding JLabels to a JList?

java swing jlabel jlist

So far, I've tried simply going through my labels and adding each one to the list's list model with: