110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tesing
{
class Program
{
static void Main(string[] args)
{
string test = "He+llo world!)";
string u;
u = test.Substring(0, 1);
test.Remove(1);
Console.WriteLine("剪切下来的字符串为{0},Test字符串的大小为{1}",u,test.Length);
int Cout;
char[] Signe = new char[] { '(', ')', '+', '-', '*', '/' };
test.Replace("!", "#");
Console.WriteLine("执行完Replace函数后的test:{0},它的长度{1}", test, test.Length);
Cout = test.IndexOfAny(Signe,0);
Console.WriteLine(Cout);
Console.ReadLine();
}
}
}
string str1 = "abc";
string str2 = str1.Remove(1);//即str1="abc",str2="a";
string str="abcdefg";
str=str.remove(1);//返回新实例的,重新赋值
str=str.Replace("a","b");//返回新实例的,重新赋值
str=str.Trim();//所有方法都要重新赋值