0
我想让无错误的用户输入。当有一个拆分符号用户可能会输入它并创建一个错误,我必须在执行创建更多行代码之前修复这个错误。有没有使用例如$%$
而不是$
字符来分割字符串的方法?如何分割使用多个字符?
这是我使用一个字符做分割:
if (!lastUsed.EmptyFile())
{
string[] allSettings = lastUsed.Text.Split('$');
int settingCount = 0;
foreach (string setting in allSettings)
{
settingCount++;
if (settingCount == 1)
{
txtText.Text = setting;
}
else if (settingCount == 2)
{
if (setting == "0") tbType.SelectedTab = tbInterval;
else tbType.SelectedTab = tbRange;
}
else if (settingCount == 3)
{
nudInterval.Value = decimal.Parse(setting);
}
else if (settingCount == 4)
{
nudMin.Value = decimal.Parse(setting);
}
else if (settingCount == 5)
{
nudMax.Value = decimal.Parse(setting);
}
}
}
您是否检查过[文档](http://msdn.microsoft.com/zh-cn/library/b873y76a.aspx)?它接受一组字符。听起来像这就是你想要的:只需指定多个字符来分割。 – 2012-01-10 05:10:17
这已经是你最后一部分http://stackoverflow.com/questions/8798603/input-string-was-not-in-a-correct-format-when-setting-a-numericupdown-value – V4Vendetta 2012-01-10 05:20:14