如何分割字符串

本文关键字:字符串 分割 何分割 | 更新日期: 2023-09-27 18:02:25

在以下示例中,

/*----------------------// kvkbl jk//bv klb /* /*gkljbgflkjbncviogf*/

如何获得/**/之间的字符串

如何分割字符串

看看这个教程

using System;
class Program
{
    static void Main()
    {
        string s = "/*there*/ is a cat";
        string s = "User name (sales)";
        int start = s.IndexOf("/*");
        int end = s.IndexOf(")*/")
        string result = s.substring(start, end - start -1)
        //result contains "there"
    }
}
string s = "there is a cat";
    //
    // Split string on spaces.
    // ... This will separate all the words.
    //
    string[] words = s.Split(' ');
    foreach (string word in words)
    {
        Console.WriteLine(word);
    }

   //Output 
     there
     is
     a
     cat