开发者

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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜