avc-acaldfald
c#里怎样才能将上面的字符串截取"-"以后的啊?即要得到acaldfald
c#里怎样才能将上面的字符串截取"-"以后的啊?即要得到acaldfald
解决方案 »
- asp.net怎样在页面上显示"生活用品"(一级分类表)及它下面的"生活二级1,生活二级2"(二级分类表),还有"纸巾","毛巾"(三级分类表)
- 在FormView控件中,table控件中的绑定控件失效,如何解决?
- 关于在ASP.NET中为DATAGRID添加合计字段的问题!
- 新手上路,一个非常急的ASP.NET问题,一定请高手帮忙,不胜感激!
- 怎样再后台代码里设置textbox的textmode属性?
- 在.aspx文件中<script src="jscommon.js" type="text/javascript"></script>包含文件无效,请问如何包含文件?
- 关于facebook api的问题
- visual studio 现在都用什么版本啊
- 发布一个简单的ComboBox的原代码,我想对正在学控件编程的朋友都有参考用途:
- 页面中callService("login","用户") 和 aspx中用代理 method("用户")
- ASP.NET重复显示数据在一个区域里,像留言板的那样。
- 请教关于ASP.net做网页问题
String.Substring (Int32) 从此实例检索子字符串。子字符串从指定的字符位置开始。
String.Substring (Int32, Int32) 从此实例检索子字符串。子字符串从指定的字符位置开始且具有指定的长度。举例如下:using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string s = "Hello C# World!";
//s1为从s中截取的位置为3的字符以后的字符子串,3表示子字符串的起始字符位置
string s1=s.Substring(3);
Console.WriteLine(s1);
//s2为从s中截取的位置为6的字符开始长度为2的字符串,6表示子字符的起始字符位置,2表示子字符长度
string s2 = s.Substring(6, 2);
Console.WriteLine(s2);
}
}
}
结果如下:lo C# World!C#这是好代码
a = a.Substring(a.IndexOf('-')+1, a.Length - a.IndexOf('-')-1);
a = a.Replace("-","");
str = str.Substring(str.IndexOf('-')+1, str.Length - str.IndexOf('-')+1);
更正下:
string str = "avc-acaldfald";
str = str.Substring(str.IndexOf('-')+1, str.Length - str.IndexOf('-')-1);
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string s = "Hello C# World!";
//s1为从s中截取的位置为3的字符以后的字符子串,3表示子字符串的起始字符位置
string s1 = s.Substring(3);
Console.WriteLine(s1);
//s2为从s中截取的位置为6的字符开始长度为2的字符串,6表示子字符的起始字符位置,2表示子字符长度
string s2 = s.Substring(6, 2);
Console.WriteLine(s2);
string s3 = s.Substring(s.IndexOf("o") + 1, s.Length - s.IndexOf("o") - 1);
Console.WriteLine(s3);
}
}
}
这种么 用8楼的方法不错。