New filters on the Home Feed, take a look!
view details

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.

10
Beginner C# programmer here, in need of help / guidance about string.Split()
Post Body

**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();
    }
}

}

Author
Account Strength
80%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
398
Link Karma
165
Comment Karma
233
Profile updated: 4 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago