- 文字列の部分取り出し
- 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", "");
int i = int.Parse(str);
最終更新:2015年08月05日 19:00