我正在尝试为PS3游戏制作基于控制台的模组应用程序。
其中一个命令就像
"杀死价值"
该值是用户定义的数字,我将如何获得"值"的文本框,所以它设置用户"杀死"他们定义的是什么。
获取值然后将其发送到标签是否是好的。经过一些编码后,玩家将会杀死"杀死"他们定义了什么?
答案 0 :(得分:2)
使用正则表达式可以使一切变得更容易。
using System.Text.RegularExpressions;
var input = "kills 67"; // Just an example!
var kill_str = Regex.Match(input, @"\d+").Value;
int kills = Int32.Parse(kill_str); // Now we have the number specified by our user
// Now, do whatever you want with the collected data
info_label.text = string.format("You specified {0} kills to be added within the hack.", kills);
答案 1 :(得分:1)
var input = "kills value"
var value = input.Split(new char[] {' '})[1];