"1515/155646"我想找出这个"/"是出现在字符串里第几个位置上然后截取"/"前的数字 和"/"后的数字
解决方案 »
- 解析xml,为何读取不到子节点的值?
- winform的this.refresh()是在哪里处理的?
- 请帮忙参考下面二种群发邮件的取舍!(win程序)
- 如何让GridView的某一字段的宽度固定
- 用VS2003部署,让服务程序安装完后立即启动服务并且选中“允许服务与桌面交互”及添加服务描述的方法
- .net应用程序转移路径问题
- 求解!!!!!!!!!!!!!!!!!!!!1
- visual studio为什么其他电脑debug的时候有一个会不停调用的方法那里加入断点那里不会中断?
- 请问怎么访问https加密的内容。
- 哪有C#的开发工具阿
- C# 输入控件TextBox样式问题
- C# HTTP SOAP传输协议
用Split()可以进行分割操作!
第二个用split
string str = "1515/155646"; Console.WriteLine(str.IndexOf('/')); var s = str.Split('/');
Console.WriteLine(s[0]);
Console.WriteLine(s[1]);
int i=str.IndexOf('/');
string str1 = str.Substring(0, i);
string str2 = str.Substring(i+1);
int index = msg.IndexOf('/');///获取其索引
MessageBox.Show(index.ToString(),"提示");///分割操作;
string[] str = msg.Split(new char[] {'/' }, StringSplitOptions.RemoveEmptyEntries);
string output="";
for (int i = 0; i < str.Length;i++ )
{
output=output+str[i];
}
MessageBox.Show(output);
}你可以改进下!
string[] tempList = temp.Split('/');
temp = string.Empty; for (int i = 0; i < tempList.Length; i++)
{
temp = temp + tempList[i];
}
int num=str.IndexOf(@"/");
然后截取"/"前的数字 和"/"后的数字
string /前面的字符串=str.substring(0,num);
string /后面的字符串=str.substring(num,str.length);