错误 :类、结构或接口成员声明中的标记“(”无效 该怎么修改 必定采纳,大神解答
发布网友
发布时间:2022-04-30 04:34
我来回答
共1个回答
热心网友
时间:2023-10-13 01:32
正确代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace shiyansan2
{
public class student
{
private string name;
private string no;
private string kecheng;
private int chengji;
public student(string Namea, string Noa, string Kechenga, int Chengjia)
{
name = Namea;
no = Noa;
chengji = Chengjia;
kecheng = Kechenga;
}
public string Name
{
get { return name; }
set { name = value; }
}
public string No
{
get { return no; }
set { no = value; }
}
public string Kecheng
{
get { return kecheng; }
set { kecheng = value; }
}
public int Chengji
{
get { return chengji; }
set { chengji = (value > 0 && value <= 100) ? value : 0; }
}
}
public class gaozhong : student
{
public gaozhong(string Namea, string Noa, string Kechenga, int Chengjia) :
base(Namea, Noa, Kechenga, Chengjia) { }
}
public class benke : student
{
public benke(string Namea, string Noa, string Kechenga, int Chengjia) :
base(Namea, Noa, Kechenga, Chengjia) { }
}
class yanjiu : student
{
private string shi;
public string Daoshi
{
get { return shi; }
set { shi = value; }
}
public yanjiu(string q, string w, string r, int e, string t)
: base(q, w, r, e)
{
shi = t;
}
}
class program
{
static void Main()
{
gaozhong a = new gaozhong("张居正", "B1205000", "*", 80);
benke b = new benke("黄周宝", "B1205001", "数学", 60);
yanjiu c = new yanjiu("黄州宝", "B1205002", "语文", 90, "李明");
Console.Write("学生信息如下\n");
Console.WriteLine("姓名\t{0},学号\t{1},课程\t{2},成绩{3}\t", a.Name, a.No, a.Kecheng, a.Chengji);
Console.WriteLine("姓名\t{0},学号\t{1},课程\t{2},成绩{3}\t", b.Name, b.No, b.Kecheng, b.Chengji);
Console.WriteLine("姓名\t{0},学号\t{1},课程\t{2},成绩{3}\t,导师{4}\t", c.Name, c.No, c.Kecheng, c.Chengji, c.Daoshi);
Console.Read();
}
}
}
原来的错误太多,没有逐一指出
热心网友
时间:2023-10-13 01:32
正确代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace shiyansan2
{
public class student
{
private string name;
private string no;
private string kecheng;
private int chengji;
public student(string Namea, string Noa, string Kechenga, int Chengjia)
{
name = Namea;
no = Noa;
chengji = Chengjia;
kecheng = Kechenga;
}
public string Name
{
get { return name; }
set { name = value; }
}
public string No
{
get { return no; }
set { no = value; }
}
public string Kecheng
{
get { return kecheng; }
set { kecheng = value; }
}
public int Chengji
{
get { return chengji; }
set { chengji = (value > 0 && value <= 100) ? value : 0; }
}
}
public class gaozhong : student
{
public gaozhong(string Namea, string Noa, string Kechenga, int Chengjia) :
base(Namea, Noa, Kechenga, Chengjia) { }
}
public class benke : student
{
public benke(string Namea, string Noa, string Kechenga, int Chengjia) :
base(Namea, Noa, Kechenga, Chengjia) { }
}
class yanjiu : student
{
private string shi;
public string Daoshi
{
get { return shi; }
set { shi = value; }
}
public yanjiu(string q, string w, string r, int e, string t)
: base(q, w, r, e)
{
shi = t;
}
}
class program
{
static void Main()
{
gaozhong a = new gaozhong("张居正", "B1205000", "*", 80);
benke b = new benke("黄周宝", "B1205001", "数学", 60);
yanjiu c = new yanjiu("黄州宝", "B1205002", "语文", 90, "李明");
Console.Write("学生信息如下\n");
Console.WriteLine("姓名\t{0},学号\t{1},课程\t{2},成绩{3}\t", a.Name, a.No, a.Kecheng, a.Chengji);
Console.WriteLine("姓名\t{0},学号\t{1},课程\t{2},成绩{3}\t", b.Name, b.No, b.Kecheng, b.Chengji);
Console.WriteLine("姓名\t{0},学号\t{1},课程\t{2},成绩{3}\t,导师{4}\t", c.Name, c.No, c.Kecheng, c.Chengji, c.Daoshi);
Console.Read();
}
}
}
原来的错误太多,没有逐一指出