I'm programming in JScript.NET which is similar to C# . I want to split a string on multiple characters, in this case " - ".
The problem is when I do that like this (which should be the way to do it according to this thread):
var text = "test - test2";
var array = [" - "];
var val = text.Split(array, StringSplitOptions.None);
I get "Ambiguous match found". This is because the String class has both a Split(Char[], StringSplitOptions)
and a Split(String[], StringSplitOptions)
function, and the compiler doesn't know which one to use.
So my question is then. How do I tell the compiler that I'm using a string array when the arrays in JScript.NET are dynamically typed?
Edit: As far as I know, JScript.NET use the same APIs as C#. So this is the String class I'm using. However, I think the syntax is the same as JavaScript. Maybe someone could confirm this?
Edit2: So if there is a way to enforce a type in JScript.NET so the compiler knows which type is used, I guess that would be the answer for my case as well? JScript.NET does not have the same syntax as C#.