Use the Split() method to split strings in CSharp

Description

The following code shows how to use the Split() method to split strings.

Example


  /*  w  w w  .  ja v  a  2 s  .com*/
  
  
      
using System;

class MainClass {

    public static void Main() {
        string[] myStrings = {"To", "be", "or", "not","to", "be"};
        string myString9 = String.Join(".", myStrings);
        myStrings = myString9.Split('.');
        foreach (string mySplitString in myStrings) {
            Console.WriteLine("mySplitString = " + mySplitString);
        }
    
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var