Dart インデックス番号を指定して文字列から文字を抽出する方法

環境
Windows 11 Pro 64bit
Dart 2.18.6

構文
文字列[インデックス番号]
インデックス番号を指定して文字列から文字を抽出するには、「文字列[] 」を使用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
void main() {
String str = '東京都新宿区';
print(str[0]);
print(str[1]);
print(str[2]);
}
void main() { String str = '東京都新宿区'; print(str[0]); print(str[1]); print(str[2]); }
void main() {
  
  String str = '東京都新宿区';

  print(str[0]); 
  print(str[1]); 
  print(str[2]); 
}

実行結果


Dart

Posted by arkgame