C#魔将-lesson_05-字符串
作者:
疯帮主 | 来源:发表于
2018-11-14 10:40 被阅读0次
创建 String 对象
string fname;
fname = "Rowan";
Console.WriteLine(fname);
string fname2 = "hello";
fname2 += "world";
Console.WriteLine(fname2);

image.png
String 类的属性
属性 |
描述 |
Chars |
在当前 String 对象中获取 Char 对象的指定位置。 |
Length |
在当前的 String 对象中获取字符数。 |
String 类的方法
以下列出几个常见的方法,详情请看参考文档或官方文档
方法 |
描述 |
public bool Contains( string value ) |
返回一个表示指定 string 对象是否出现在字符串中的值。 |
public string Insert( int startIndex, string value ) |
返回一个新的字符串,其中,指定的字符串被插入在当前 string 对象的指定索引位置 |
public string[] Split( params char[] separator ) |
返回一个字符串数组,包含当前的 string 对象中的子字符串,子字符串是使用指定的 Unicode 字符数组中的元素进行分隔的。 |
public string ToLower() |
把字符串转换为小写并返回。 |
35 public string ToUpper() |
把字符串转换为大写并返回。 |
public string Replace( char oldChar, char newChar ) |
把当前 string 对象中,所有指定的 Unicode 字符替换为另一个指定的 Unicode 字符,并返回新的字符串。 |
参考文档:http://www.runoob.com/csharp/csharp-string.html
本文标题:C#魔将-lesson_05-字符串
本文链接:https://www.haomeiwen.com/subject/tsydfqtx.html
网友评论