using System;
namespace dString
{
class Program
{
static void Main(string[] args)
{
//声明一个字符串
string name = "QianFeng";
foreach (var item in name) {
Console.WriteLine(item);
}
Console.WriteLine(name[0]);
char[] words = { 'U', 'n', 'i', 't', 'y' };
#region
string name1 = "xiaoming";
string name2 = "ming";
int i=name1.CompareTo(name2);
Console.WriteLine(i);
#endregion
//Contains,判断字符串中是否包含某个字符
string words1 = "I love you";
bool isContains=words1.Contains("love");
Console.WriteLine(isContains);
//移除
string words2 = "你爱我吗?";
string words3=words2.Remove(2);
string words4 = words2.Remove(2,1);
Console.WriteLine(words4);}
}
}
C#---字符串
最新推荐文章于 2024-11-12 00:10:25 发布