Im working on a game and I want to identify pickups based on their names, is there a substring function so I can get a string of the other string from point a to point b?
thanks
Im working on a game and I want to identify pickups based on their names, is there a substring function so I can get a string of the other string from point a to point b?
thanks
Yes, there’s a method Substring. (also, Substring with one argument)
Example:
print("foo bar".Substring(2, 4));
will output:
o ba
There are lots of useful C# stuff you can do with strings such as:
yourString.Substring(int startIndex, int length)
string str = null;
string retString = null;
str = “This is substring test”;
retString = str.Substring(8, 9);
retString willreturn word “substring”
groval
One of the best blogs I’ve read on this topic is here:
It performs benchmarks using several methods to see what the fastest way is to find a string within a string.
Excellent read if you’re into speed and micro-optimizing code.