String Split() - C# Tutorial
C# Course / Strings / String Split()

String Split()

BLUF: Mastering String Split() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Split()

C# is a powerful, modern language for enterprise solutions. Discover how String Split() enhances your development workflow in the guide below.

The C# Split function divides a string into multiple substrings based on specified characters within an array and outputs an array of strings.

Signature

Example

public string[] Split(params Char[] ch)
public string[] Split(Char[], Int32)
[ComVisibleAttribute(false)]
public string[] Split(Char[], Int32, StringSplitOptions)
[ComVisibleAttribute(false)]
public string[] Split(Char[], StringSplitOptions)
[ComVisibleAttribute(false)]
public string[] Split(String[], Int32, StringSplitOptions)
public string[] Split(String[], StringSplitOptions)

Parameter

ch: it is a character type array.

Return

It returns array of string

C# String Split Method Example

Example

using System; 
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
           string s1 = "Hello C Sharp";
           string[] s2 = s1.Split(' ');
           foreach (string s3 in s2)
           {
	        Console.WriteLine(s3);
           }
         }  
      }

Output:

Output

Hello
C
Sharp

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience