Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9124501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:35:08+00:00 2026-06-17T06:35:08+00:00

Are there any valid reasons why there isn’t an overload of the String.Split which

  • 0

Are there any valid reasons why there isn’t an overload of the String.Split which accepts a delimiter string and a text to be split?

string[] Split(string delimiter)

which could then be used like

string input = "This - is - an - example";
string[] splitted = input.Split(" - ");
// results in:
//  { "This", "is", "an", "example" }

I really know, that I can create an extention method easily, but there must be valid reason why this has not been added.

Please note, that I am not looking for a solution of how to split a string using a string delimiter, I am rather looking for an explanation, why such an overload could cause problems. This is because I don’t think it would really cause problems and I find it really hard for a beginners to understand why we have to pass an actual string[] instead of a simple string as a delimiter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:35:10+00:00Added an answer on June 17, 2026 at 6:35 am

    Tweaking the question to be “Why is the StringSplitOptions parameter compulsory when calling String.Split() with a String[] argument?” might provide an answer to your question.

    Note that there’s not actually a String.Split() overload which accepts a single character. The overload takes a Char[] but as it’s a params array you can call it with a single character and it is implicitly cast to a Char[]. e.g.

    "1,2,3,4,5".Split(',');
    

    calls the same Split() overload as

    "1,2,3,4,5".Split(new[] { ',' });
    

    If there were an overload of Split() which accepted a single argument of String[] then you would be able to call Split by passing a single string argument.

    However that overload doesn’t exist and StringSplitOptions is compulsory when passing a String[] to Split. As to why StringSplitOptions is compulsory, I can only theorize but it may be that when splitting with a string, the likelihood of a complex split for the algorithm to deal with increases significantly. To provide expected results for these cases, it is preferable for the behaviour of the method, when finding multiple delimiters next to each other, to be defined. i.e. StringSplitOptions is compulsory.

    You might argue that you could have a Split(String, StringSplitOptions) overload, but as Ilya Ivanov mentioned in the answer above, you need to stop somewhere and there is a perfectly good way of passing a single string in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to write a valid header/link/image? Something like <a href=index.html><h1 id=logo>Company
Is there any way to format this so it's a valid expression, without adding
Is there any cross-browser css sticky footer with W3C valid css and semantic X/HTML?
Is there any way to enclose <style> tags within <body> and still have valid
I know that technically all three ways below are valid, but is there any
Are there any reasons why Equals or GetHashCode should be overriden in entities when
While there might be valid cases where such method overloadings could become ambiguous, why
Is there any functional difference in Python between a try statement and an if
Is there any way in Notepad++ (or even with another tool) to change the
Is there any way I can set a formatter on models that will convert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.