请高手忙办把VB代码改成C#
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#怎么实现
------解决方案--------------------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;
}
}
------解决方案--------------------楼上的应该可以