「文字列操作」の編集履歴(バックアップ)一覧はこちら
文字列操作 - (2015/08/05 (水) 19:00:28) の1つ前との変更点
追加された行は緑色になります。
削除された行は赤色になります。
-文字列の長さ
--b = a.Length;
-文字列の部分取り出し
--b = a.Substring(0, 2); //先頭から2文字→文字
--b = a.Substring(1, 2); //2文字目から3文字→字列
--b = a.Substring(1); //3文字目以降全部→字列A
-文字列の分割
--string a = "name<>date<>text";
--分割文字を'<>'として分割する
--string[] b = a.Split("<>");
--b[0]にはname
--b[1]にはdate
--b[2]にはtextが入る
-文字列検索
--string a = "name<>date<>text";
--int b = a.IndexOf('<>');
--先頭を 0とした,最初に発見した文字の位置(=文字数)が入る
--この場合、b=4
-文字列の置換
--string text = text.Replace ("abc", "");
-左右の空白をとる
--text = text.Trim()
-文字列を数字にする
int i = int.Parse(str);
-文字列の長さ
--b = a.Length;
-文字列の部分取り出し
--b = a.Substring(0, 2); //先頭から2文字→文字
--b = a.Substring(1, 2); //2文字目から3文字→字列
--b = a.Substring(1); //3文字目以降全部→字列A
-文字列の分割
--string a = "name<>date<>text";
--分割文字を'<>'として分割する
--string[] b = a.Split(',');
--b[0]にはname
--b[1]にはdate
--b[2]にはtextが入る
-複数の区切り文字を使う
--char[] KUGIRI = {' ', ',','?','.','!',';'};
--string[] b = a.Split(KUGIRI);
-文字列検索
--string a = "name<>date<>text";
--int b = a.IndexOf('<>');
--先頭を 0とした,最初に発見した文字の位置(=文字数)が入る
--この場合、b=4
-文字列の置換
--string text = text.Replace ("abc", "");
-左右の空白をとる
--text = text.Trim()
-文字列を数字にする
int i = int.Parse(str);