赞
踩
string ax = "我是大帅哥";
char temp = ax[2];
Console.WriteLine(temp);
>>>大
using System; namespace tiamo { public class Program { static void Main(string[] args) { string ax = "我是大帅哥"; // 定义一个字符串 for(int i = 0; i < ax.Length; i++) { Console.WriteLine(ax[i]); // 利用循环索引,打印 } } } }
>>>我
>>>是
>>>大
>>>帅
>>>哥
string ax = "我是大帅哥,我很想低调,但这很难";
string[] temp = ax.Split(",");
foreach (string x in temp)
{
Console.WriteLine(x);
}
>>>我是大帅哥
>>>我很想低调
>>>但这很难
string ax = "精益求精,至臻至善";
string temp = ax.Replace("至臻至善", "成就完美");
Console.WriteLine(temp);
>>>精益求精,成就完美
string ax = "我是大帅哥";
string temp = ax.Substring(2); // 从索引2开始提取(包括索引2)
Console.WriteLine(temp);
string temp_2 = ax.Substring(1, 3); // 从索引1开始提取,只提取3个字符
Console.WriteLine(temp_2);
>>>大帅哥
>>>是大帅
string ax = "我是大帅哥";
string temp = ax.Insert(2, "超级");
Console.WriteLine(temp);
>>>我是超级大帅哥
string ax = "我是大帅哥";
string temp = ax.Remove(1);
Console.WriteLine(temp);
string temp_2 = ax.Remove(2, 2);
Console.WriteLine(temp_2);
>>>我是
>>>我是哥
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。