当前位置:编程学习 > C#/ASP.NET >>

console.read 问题;

int i=Console.Read 总不能通过编译,“无法将方法组“Read”转换为非委托类型“int”。”这怎么回事啊 ? --------------------编程问答--------------------

int i=0;
int.TryParse(Console.ReadLine(),out i);
--------------------编程问答-------------------- 应该是 int i=Convert.ToInt32(Console.WriteLine()); --------------------编程问答-------------------- 错了 应该是: int i=Convert.ToInt32(Console.ReadLine());或者是int i=Convert.ToInt32(Console.Read()); --------------------编程问答-------------------- 任何打在Console上和从Console读入的都是string。
2楼的方法好 --------------------编程问答-------------------- console.read的返回值就是int啊?为什么还要转换呢。 --------------------编程问答-------------------- 你没打括号吧
console.read(); --------------------编程问答-------------------- 直接
int i;
i=Console.Read();
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,