刚接触C#,遇到一个简单 问题

[复制链接]
查看11 | 回复2 | 2010-9-28 13:24:18 | 显示全部楼层 |阅读模式
有错误:“错误 1 找不到类型或命名空间名称“Graduate”(是否缺少 using 指令或程序集引用?) D:\Backup\我的文档\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs 77 13 ConsoleApplication2”
这是怎么回事?求救!!!
程序如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace student
{

public class Student

{

private string student_id;

private string student_name;

public static string information = "学生上课情况表";

public Student(string id, string name)

{

student_id = id;

student_name = name;

}

public string StudentID

{

get

{

return student_id;

}

set

{

student_id = value;

}

}

public string StudentName

{

get

{

return student_name;

}

set

{

student_name = value;

}

}

public string AddressClass(int i)

{

string CAddress;

if (i == 1)

CAddress = "2#楼";

else

CAddress = "5#楼";

return CAddress;

}

public class Graduate : Student

{

private string teacher_name;

public Graduate(string i, string j, string tn)

: base(i, j)

{

teacher_name = tn;

}

public string TeacherName

{

get

{

return teacher_name;

}

set

{

teacher_name = value;

}

}

}

}

class Program

{

public static void Main(string[] args)

{

Console.WriteLine("{0}", Student.information);

Graduate gs = new Graduate("200201", "wang ming", "zhang yang");

Console.WriteLine("研究生学号:{0}", gs.student_id);

Console.WriteLine("研究生姓名:{0}", gs.student_name);

Console.WriteLine("研究生上课地点:{0}", gs.AddressClass(1));

Console.WriteLine("教师姓名:{0}", gs.teacher_name);

Console.ReadKey();

}

}
}

回复

使用道具 举报

千问 | 2010-9-28 13:24:18 | 显示全部楼层
括号范围错了 试试这样using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace student{
public class Student
{
private string student_id;
private string student_name;
public static string information = "学生上课情况表";
public Student(string id, strin
回复

使用道具 举报

千问 | 2010-9-28 13:24:18 | 显示全部楼层
Graduate 把鼠标放上去 右下角有个东东 一点就引用上命名空间了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行