Function Cut(sContent, iLeft, iRight)
        If Len(sContent)>(iLeft+iRight) Then
                Cut = Left(sContent, iLeft) & "..." & Right(sContent, iRight)
        Else
                Cut = sContent
        End If
End Function想实现省略中间字符字符的功能,上面是vb的用C#怎么实现

解决方案 »

  1.   

    public object Cut(object sContent, object iLeft, object iRight) 

        object functionReturnValue = null; 
        if (Strings.Len(sContent) > (iLeft + iRight)) { 
            functionReturnValue = Strings.Left(sContent, iLeft) + "..." + Strings.Right(sContent, iRight); 
        } 
        else { 
            functionReturnValue = sContent; 
        } 
        return functionReturnValue; 
      

  2.   

    Function Cut(sContent, iLeft, iRight) 
            If Len(sContent)>(iLeft+iRight) Then 
                    Cut = Left(sContent, iLeft) & "..." & Right(sContent, iRight) 
            Else 
                    Cut = sContent 
            End If 
    End Function
    对应c#
    string Cut(string sContent,int iLeft,int iRight)
    {
       if(sContent.Length>iLeft+iRight)
       {
          return sContent.SubString(0,iLeft)+"..."+sContent.SubString(sContent.Length-iRight);
       }else
       {
          return sContent;
       }
    }
      

  3.   


    public object Cut(object sContent, object iLeft, object iRight) 

        object functionReturnValue = null; 
        if (Strings.Len(sContent) > (iLeft + iRight)) { 
            functionReturnValue = Strings.Left(sContent, iLeft) + "..." + Strings.Right(sContent, iRight); 
        } 
        else { 
            functionReturnValue = sContent; 
        } 
        return functionReturnValue;