csharp string split by length

Code Example - csharp string split by length

                
                        static IEnumerable<string> Split(string str, int chunkSize)
{
    return Enumerable.Range(0, str.Length / chunkSize)
        .Select(i => str.Substring(i * chunkSize, chunkSize));
}
                    
                
 

c sharp split string

                        
                                // To split a string use 'Split()', you can choose where to split
string text = "Hello World!"
string[] textSplit = text.Split(" ");
// Output:
// ["Hello", "World!"]
                            
                        
 

Related code examples