【发布时间】:2016-01-20 10:43:33
【问题描述】:
我想在 Windows 窗体中进行验证,以便在文本值之间只允许一个空格。在c#中怎么做。提前致谢。 我不想仅在 c# 中使用任何其他方法进行此验证。请帮我做这件事。
if (e.Handled = (e.KeyChar == (char)Keys.Space))
{
MessageBox.Show("Spaces are not allowed at start");
}
}
【问题讨论】:
-
if (string.Join(" ", test.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries)) != test) ... // bad spacing -
请考虑将其中一个答案标记为已接受。