Where is Split ???

Hi there

Im trying to use Split method …
nothing fancy:

var seperators : String[ ] = [“”];

var pairs : Array = scores.data.Split( seperators );

This is what I get :

No appropriate version of ‘String.Split’ for the argument list ‘((String))’ was found.

There is no “Split” in documentation period… What ever code I found on the forum doesn’t work.

Please tell me what am I missing. Please !!!

Thanks!

Split is a .NET String method so you best check out MSDN or better the mono documentation for mono 1.2.5 on the specific methods present on System.String

The scripting reference is for Unity API stuff, so it wouldn’t have something tied to System.String in it. Take a look at System.String members in the Mono documentation.

I don’t know if it is the best way to do it, but it looks like String.Split wants char[ ], so off the top of my head, something like this should work (untested):

var myString : String = "You Know It  Happy";
var strings : String[] = myString.Split("".Chars[0]);
Debug.Log(strings[1]+"  "+strings[0]);

The JS workaround for char is to slice it:

"\t"[0]

ie

var someString:String = "Hello There Guys";
var parts:String[] = someString.Split(" "[0]);

Thanks !

Seems like something like Split should be included in Unity Docs …

Why? It isn’t specific to Unity, it is a .net thing. It doesn’t make sense to have it in Unity API docs since it isn’t part of that.

On the other hand, the Unity docs are nicer and more readable than the MSDN docs. :wink: It would be an unreasonable effort, but having all the .net stuff documented in the same way as the rest of Unity would be nice in an ideal world.

–Eric

Mono’s has a minimalist layout. Don’t know if there’s a way to search it though.

All Im saying its pretty basic hting, and it should be at least mentioned … and user can be pointed to other sources of information at the minimum.

uv been pointed. oh yeah search would show others have been pointed too :stuck_out_tongue_winking_eye:

He does have a point though. The built-in arrays are already in .NET docs, but they are heavily covered in the Unity docs too. Any important feature that may be needed regularly could be documented (or at least mentioned) if its a question that continuously comes up on the forums. I would agree that built-in arrays are a little more critical that Splitting strings though.

I think that when it comes to documentation that just documenting the Unity-specific features of the engine is a substantial enough undertaking for their team without having to worry about selectively duplicating existing docs for the .NET/Mono frameworks.

Considering there are Unity-specific classes and functions (iPhone especially) that are thin on documentation as it is, I don’t see why it would be a priority for them when the information is readily available already.

That said, a link in the scripting guide to the Mono docs couldn’t hurt, but it might not do a lot of good, either, since new users would be just as likely to miss it and come asking on the forums anyway.