Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active May 7, 2025 12:14
Show Gist options
  • Save Strelok78/53549647dc2806e8bb3c9e37df617db9 to your computer and use it in GitHub Desktop.
Save Strelok78/53549647dc2806e8bb3c9e37df617db9 to your computer and use it in GitHub Desktop.
String.Split, split string by space
namespace iJuniorPractice
{
class Program
{
static void Main(string[] args)
{
string text = "In moonlit woods, whispers of ancient tales danced " +
"\n" +
"\n " +
"with shadows, weaving dreams beneath stars' gentle, timeless gaze.";
char[] splitSymbols = { ' ', ',', '\n' };
String emptyWord = "";
string[] textSplited = text.Split(splitSymbols);
foreach (var word in textSplited)
{
if (word != emptyWord)
Console.WriteLine(word);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment