c#,split方法获得用户以空格分隔的两个数字,数组却为空,是什么情况?
用户输入两个数字,并以空格分隔,我用split方法这样写,调试时发现获得是的数组却是空的,导致我进行不了下一步了,这是什么原因?请各位大佬提点一下我这个菜鸟,谢谢!
static void Main(string[] args)
{
string s = Console.ReadLine();
string[] x = s.Split(new char[] {' '},StringSplitOptions.RemoveEmptyEntries;
int price = Convert.ToInt32(x[0]);
int discount = Convert.ToInt32(x[1]);
double newPrice = price * (discount / 100);
string k = newPrice.ToString();
Console.WriteLine(k);
//Console.WriteLine(String.Format("{0:N2}",k));
Console.ReadKey();
}