求助截取问题 请大家进来 谢谢

icuso 2010-09-25 01:03:29
现在Session["code1"].ToString() 为 9.13.0790000001RS(3G信息IT790B成品机)
有什么办法使 (3G信息IT790B成品机) 这几个字去掉
this.TextBox4.Text = Session["code1"].ToString();
效果如下
this.TextBox4.Text 的格子上体现 9.13.0790000001RS
也就是说this.TextBox4.Text="9.13.0790000001RS";

在此先谢过
...全文
64 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yoyo_ 2010-09-25
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 wuyq11 的回复:]
Session["code1"].ToString().Substring(0,Session["code1"].ToString().Indexof("(");
[/Quote]
楼上正解~~
wuyq11 2010-09-25
  • 打赏
  • 举报
回复
Session["code1"].ToString().Substring(0,Session["code1"].ToString().Indexof("(");
hongjiaoli 2010-09-25
  • 打赏
  • 举报
回复
string str=Session["code1"].ToString;
if(str.Length>16)
{
str=Session["code1"].ToString().substring(0,16);
}
cnzhyy 2010-09-25
  • 打赏
  • 举报
回复
要如何有积分呀
chen_ya_ping 2010-09-25
  • 打赏
  • 举报
回复
[Quote=引用楼主 icuso 的回复:]
现在Session["code1"].ToString() 为 9.13.0790000001RS(3G信息IT790B成品机)
有什么办法使 (3G信息IT790B成品机) 这几个字去掉
this.TextBox4.Text = Session["code1"].ToString();
效果如下
this.TextBox4.Text 的格子上体现 9.13.0790000001RS
……
[/Quote]
string str=Session["code1"].ToString();
str=str.substring(0,str.indexof("("));
textbox4.text=str;
-过客- 2010-09-25
  • 打赏
  • 举报
回复
this.TextBox4.Text = Session["code1"].ToString().Remove(Session["code1"].ToString().IndexOf("("));
q107770540 2010-09-25
  • 打赏
  • 举报
回复

void Main()
{

Regex r=new Regex(@"(?=\().*(?<=\))");
string s=r.Replace("9.13.0790000001RS(3G信息IT790B成品机)","");
Console.WriteLine(s);
}

// 结果:
//9.13.0790000001RS

q107770540 2010-09-25
  • 打赏
  • 举报
回复
正则: (?=\().*(?<=\))
MSDNXGH 2010-09-25
  • 打赏
  • 举报
回复
这个容易啊,储存的时候,不要存进去就行了。
要不这样也行
Session["code1"].ToString().substring(0,16);

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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