I want to split a string into an array. The string is as follows:
:hello:mr.zoghal:
I would like to split it as follows:
hello mr.zoghal
I tried …
string[] split = string.Split(new Char[] {':'});
and now I want to have:
string something = hello ;
string something1 = mr.zoghal;
How can I accomplish this?
For your original request:
This will produce
in accordance to your request.
Also, the line
is not legal C#.
String.Splitis an instance-level method whereas your current code is either trying to invokeSpliton an instance namedstring(not legal as “string” is a reserved keyword) or is trying to invoke a static method namedSpliton the classString(there is no such method).Edit: It isn’t exactly clear what you are asking. But I think that this will give you what you want:
Now you will have
and
both evaluate as true. Is this what you are looking for?