Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 347 Vote(s) - 3.65 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forcing specific .NET types in JScript.NET?

#1
I am using the Fiddler web debugger which uses [FiddlerScript][1] which is based on JScript.NET. I'm trying to do some simple .NET string parsing but it fails with error "**More than one method or property matches this argument list**". For example:

var ahraw: String = "one, two, three, four";
var ah: Array = ahraw.Split([',', ' '], System.StringSplitOptions.RemoveEmptyEntries);
for (var i in ah) {
FiddlerObject.alert("\"" + ah[i] + "\"");
}

[![enter image description here][2]][2]

[String.Split][3] has these prototypes:

Split(Char[], Int32, StringSplitOptions)
Split(String[], Int32, StringSplitOptions)
Split(String[], StringSplitOptions)
Split(Char[], StringSplitOptions)
Split(Char[], Int32)
Split(Char[])

Even if I add an Int32 and run it like `ahraw.Split([',', ' '], 99, System.StringSplitOptions.RemoveEmptyEntries);` or `ahraw.Split(", ", 99, System.StringSplitOptions.RemoveEmptyEntries);` it still finds multiple methods. Is it possible to force the specific .NET type? Something like `var sep: String` doesn't work either.

Of course there are other ways to split a string in JScript such as split() (note the lowercase s). I'm more interested in how I can get around this issue for when there's no javascript equivalent for the function I need to call, so I have to call a .NET funciton.


[1]:

[To see links please register here]

[2]:

[3]:

[To see links please register here]

Reply

#2
As mentioned in the comments, these days it would probably be easier to just use C# as a scripting language (could be set in `Tools -> Options -> Scripting -> Language`).

If you however have/want to stick to JScript.NET (e.g. if you already have complex customizations), you can work around the problem by declaring [typed array][1] for the separators, otherwise the compiler cannot distinguish which of the `Split(String[], StringSplitOptions)` and `Split(Char[], StringSplitOptions)` overloads to call.

<!-- language: csharp -->

var ahraw: String = "one, two, three, four";
var separators: Char[] = [',', ' '];
var ah: Array = ahraw.Split(separators, System.StringSplitOptions.RemoveEmptyEntries);
for (var i in ah) {
FiddlerObject.alert("\"" + ah[i] + "\"");
}


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through