How to split a string by word into an array of strings in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "c# java c c++ java python";

            string[] arr = s.Split(new[] { "java" }, StringSplitOptions.None);

            foreach (string part in arr)
            {
                Console.WriteLine(part);
            }
        }
    }
}

/*
run:

c#
 c c++
 python

*/

 



answered Jan 23, 2017 by avibootz

Related questions

1 answer 204 views
1 answer 171 views
1 answer 205 views
1 answer 222 views
...