How to split string on backslash in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string s = @"C:\Users\Name\Documents\C#\Examples";

        string[] arr = s.Split(new char[] { '\\' });

        foreach (string element in arr)
            Console.WriteLine(element);
    }
}




/*
run:

C:
Users
Name
Documents
C#
Examples

*/

 



answered Oct 26, 2022 by avibootz

Related questions

...