Converting VbSCript Simple Function (UCase,Left,Instr) to C# function
I have got below function in VBSCript. How can this be writtern in 开发者_如何学GoC#.
Dim Title 'As String
Function getNavID(Title)
getNavID=UCase(Left(Title, InStr(Title, ". ") -1))
End Function
public string getNavID(string Title)
{
var index = Title.IndexOf(". ");
return Title.Substring(0, index -1).ToUpper();
}
Use this:
string getNavID(string Title)
{
int a = Title.IndexOf('.');
if (a >= 0) Title = Title.Substring(0, a - 1);
return Title.ToUpper();
}
精彩评论