C#下string.Remove和Replace()无效
小菜今天自学C#然后对一个string类型的对象操作,一开始想删除开头的字母,然后将字符串中的某个字母替换掉,可是试过没有用,本菜初学,求大神指教,感激不尽。
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();
}
}
}