请高手忙办把VB代码改成C#

tongling15 2008-06-29 02:14:33
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#怎么实现
...全文
98 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ericzhangbo1982111 2008-06-30
  • 打赏
  • 举报
回复

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;
}
yumanqing 2008-06-30
  • 打赏
  • 举报
回复
楼上的应该可以
xhan2000 2008-06-30
  • 打赏
  • 举报
回复
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;
}
}
aino77 2008-06-30
  • 打赏
  • 举报
回复
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;
}

tongling15 2008-06-30
  • 打赏
  • 举报
回复
没人知道吗?

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧