c# - 无法将string类型隐士转换为int(cs0029)
本文介绍了c# - 无法将string类型隐士转换为int(cs0029)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
csharpdeveloper 提示 无法将string类型隐士转换为int(cs0029)
这是为什么呢? 新手求教
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleTest
{
class ConsoleTest
{
static void Main(string[] args)
{
Console.WriteLine("请输入两个学生的名字");
string name1=Console.ReadLine();
string name2=Console.ReadLine();
Console.WriteLine("请输入两个学生的成绩");
int x = Console.ReadLine();
int y = Console.ReadLine();
Console.WriteLine("第一个学生的姓名{0},成绩{1}",name1,x);
Console.WriteLine("第二个学生的姓名{0},成绩{1}",name2,y);
Console.ReadKey();
}
}
}
解决方案
public static string ReadLine();
ReadLine 返回的是string
这篇关于c# - 无法将string类型隐士转换为int(cs0029)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文