どうも、ちょげ(@chogetarou)です。
Remove()を使って文字列(string)の先頭の文字を削除する方法を紹介します。
方法

Remove()を使って文字列(string)の先頭の文字を削除するには、2つの引数を使います。
まず、文字列からRemove()を呼び出します。
そして、Remove()の第1引数に0、第2引数に1を指定します。
string result = text.Remove(0, 1);
上記のRemove()は、呼び出した文字列の先頭の文字を削除した文字列を返します。
使用例
public class Sample{
public static void Main(){
string text = "Python";
string text2 = "Swift";
string text3 = "Kotlin";
string result = text.Remove(0, 1);
string result2 = text2.Remove(0, 1);
string result3 = text3.Remove(0, 1);
System.Console.WriteLine(result);
System.Console.WriteLine(result2);
System.Console.WriteLine(result3);
}
}
出力:
ython
wift
otlin
コメント