如题, 在C中有scnaf("%d%d%d",x,y,z)可以在运行时在一行中为多个参数赋值用空格分隔,而在C#中必须以回车结束才能为一个变量赋值.请问怎么才能在运行时在一行中为多个变量赋值并以特定字串分隔. year=Int32.Parse( Console.ReadLine());
month = Int32.Parse(Console.ReadLine());
day = Int32.Parse(Console.ReadLine());
怎么把以上三条代码的功能合成一条?比如输入:2008-8-8 "/n" 就能为三个变量赋值?
month = Int32.Parse(Console.ReadLine());
day = Int32.Parse(Console.ReadLine());
怎么把以上三条代码的功能合成一条?比如输入:2008-8-8 "/n" 就能为三个变量赋值?
string d= Console.ReadLine();
输入2008-8-12
string[] v= d.Split(new char[] { '-'});
int year=Convert.ToInt32(v[0]);
int month=Convert.ToInt32(v[1]);
string strInput=Console.ReadLine();
string[] time=strInput.Split(' ');
if(time.length==3)
{
int year=1,month=1,day=1;
int.TryParse(time[1],out year);
int.TryParse(time[1],out month);
int.TryParse(time[1],out day);
DateTime newTime=new DateTime(year,month,day);
}