I'm playing around with a class library in Visual Studio, integrating ExcelDNA to make a (few) User Defined Function for Excel.
The only error I am receiving is for the top "public static string StrCase" statement, but I haven't been able to figure out what the problem is. What do I need to do to get rid of this error?...what am I missing?
Error CS0161 not all code paths return a value
...I'm completely new to C#, by the way. Thanks!
The only error I am receiving is for the top "public static string StrCase" statement, but I haven't been able to figure out what the problem is. What do I need to do to get rid of this error?...what am I missing?
Error CS0161 not all code paths return a value
...I'm completely new to C#, by the way. Thanks!
Code:
public static string StrCase
( [ExcelArgument(Name="String",Description ="Text string that is to have letters' case change.")]
string str,
[ExcelArgument(Name ="Case",Description ="0 = no case change,
1 = change to UPPERCASE, 2 = change to lowercase, 3 = Change To Title Case")]
byte bCase = 0
)
{ if (bCase <= 0 || bCase > 3) // "||" is the C# OR operator
{ return str;
}
else
{ TextInfo strTI = new CultureInfo("en-US", false).TextInfo;
if (bCase != 1)
{ return str.ToLower();
}
if (bCase != 2) // "!=" is the equivalence operator
{ return str.ToUpper();
}
if (bCase != 3)
{ str = strTI.ToTitleCase(str);
return str;
}
}
}