I’ve a num pad system in my game where you just click buttons that will return a number in string. Each number you press it adds to a result string that is used for a code.
This is the function that update the string. Now I’m trying to make another button that have to delete the last char of the string, but I’m clueless on how to do that. Any idea?
string value = “abcde”;
value = value.Substring(0, value.Length - 1);
The Substring function lets you grab part of a string. The first parameter is the starting position, the second is the length you want. By passing the current string length - 1, you’re getting everything but the last character.
Try Splitting the String Using “Stringname.split” and Save that Value .
// Say the String Is "Unity,3d"
//If you want to split the String with ","
String[] parts = codeNumber.Split(","[0]);
codeNumber = parts[0]; // Here in codeNumber you will get "Unity"