// .
Using System;
class TrimPadDemo { static void Main() { string str = "";
Console.WriteLine(" : " + str);
// , str = str.PadLeft(10);
Console.WriteLine("I" + str + "I");
// , str = str.PadRight(20);
Console.WriteLine("I" + str + "I");
// , str = str.Trim();
Console.WriteLine("|" + str + "I");
// # , str = str.PadLeft (10, '#');
Console.WriteLine ("|" + str + "I");
// # , str = str.PadRight(20, '#');
Console.WriteLine("|" + str + "I");
// #. str = str.Trim('#');
Console.WriteLine("|" + str + "|");
}
}
.
: I |
| |
||
I ######|
|################|
I |
,
Insert (): public string Insert(int startlndex, string value)
value , startlndex. .
Remove (). .
public string Remove(int startlndex)
public string Remove(int startlndex, int count)
Remove () , , startlndex, . , count, , startlndex. .
Replace (). .
public string Replace(char oldChar, char newChar) public string Replace(string oldValue, string newValue)
Replace () oldChar newChar. oldValue newValue. .
Insert (), Remove () Replace().
// , .
Using System;
class InsRepRevDemO { static void Main() {
string str = " ";
Console.WriteLine(" : " + str);
// .
str = str.Insert(4, " ");
Console.WriteLine(str);
// .
str = str.Replace("", " ");
Console.WriteLine (str);
// str = str.Replace('', 'X');
Console.WriteLine(str);
// , str = str.Remove(4, 5);
|
|
Console.WriteLine(str);
.
: _
String , , ToUpper () ToLower (). .
Public string ToLower() public string ToUpper()
ToLower () , ToUpper () . . , .
public string ToLower (Culturelnfo culture) public string ToUpper(Culturelnfo culture)
. .
, ToUpper Invariant () ToLowerlnvariant().
Public string ToUpperlnvariant () public string ToLowerlnvariant()