错误 :类、结构或接口成员声明中的标记“(”无效 该怎么修改 必定采纳,大神解答
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespa...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace shiyansan2
{
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 class benke:student
{
}
class yanjiu:student
{
private string daoshi;
public string Daoshi
{
get{return daoshi;}
set{daoshi=value;}
}
public yanjiu(string q ,string w,string r ,int e,string t ):base(q,w,r,e)
{
daoshi=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()
}
} 展开
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace shiyansan2
{
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 class benke:student
{
}
class yanjiu:student
{
private string daoshi;
public string Daoshi
{
get{return daoshi;}
set{daoshi=value;}
}
public yanjiu(string q ,string w,string r ,int e,string t ):base(q,w,r,e)
{
daoshi=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()
}
} 展开
1个回答
展开全部
正确代码如下
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 daoshi;
public string Daoshi
{
get { return daoshi; }
set { daoshi = value; }
}
public yanjiu(string q, string w, string r, int e, string t)
: base(q, w, r, e)
{
daoshi = 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();
}
}
}
原来的错误太多,没有逐一指出
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询