This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
**EDIT: I'm an idiot =\ , was pointed out that Console.WriteLine was blank and did not include item, Console.WriteLine(item);
Hello everyone. I'm completely new to programming, and I started learning C# recently (loving it so far), however I've become frustrated with the string.Split() method.
I'm just trying out a very simple program, in order to grasp the concept of string.Split(). Thus, my program should take the input "Jared, was, here", and split it with the "," delimiter.
However, the output is three blank spaces. I've tried using StringSplitOptions.RemoveEmptyEntires and it still returns three blank spaces. Please help
using System; using System.Collections.Generic;
{ class Program { static void Main() { string str = "Jared, was, here";
string[] strSplit = str.Split(',');
foreach (string item in strSplit)
{
Console.WriteLine();
}
Console.ReadLine();
}
}
}
And with StringSplitOptions
using System; using System.Collections.Generic;
namespace StringSplitPractice { class Program { static void Main() { string str = "Jared, was, here";
string[] strSplit = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in strSplit)
{
Console.WriteLine();
}
Console.ReadLine();
}
}
}
Post Details
- Posted
- 9 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/csharp/comm...