logo
  • 教程列表
  • SO官方文檔
  • 常見字串操作
    • 格式化字串
    • 將字串填充到固定長度
    • 正確地反轉一個字串
    • 從字串的右側獲取 x 個字元
    • 使用 String.IsNullOrEmpty() 和 String.IsNullOrWhiteSpace() 檢查空字串
    • 關閉字串開頭和結尾的不需要的字元
    • 從 Array 構造一個字串
    • 使用 ToString 格式化
    • 將十進位制數轉換為 BinaryOctal 和十六進位制格式
    • 按特定字元拆分字串
    • 獲取給定字串的子字串
    • 確定字串是否以給定序列開頭
    • 將一組字串連線到一個新字串
    • 獲取特定索引處的 char 並列舉該字串
    • 用另一個字串拆分字串
    • 替換字串中的字串
    • 更改 String 中字元的大小寫
    • 將一個字串陣列連線成一個字串
    • 字串連線
  1. StackOverflow 文件
  2. C# Language 教程
  3. 常見字串操作
  4. 按特定字元拆分字串

按特定字元拆分字串

Created: November-22, 2018

string helloWorld = "hello world, how is it going?";
string[] parts1 = helloWorld.Split(',');

//parts1: ["hello world", " how is it going?"]

string[] parts2 = helloWorld.Split(' ');

//parts2: ["hello", "world,", "how", "is", "it", "going?"]
  • 獲取給定字串的子字串
  • 將十進位制數轉換為 BinaryOctal 和十六進位制格式

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明