C# 错误 1 找不到类型或命名空间名称“Student”(是否缺少 using 指令或程序集引用?) 5
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespa...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Class
{
public class StudentClass
{
private Student[] students = new Student[35];
public Student this[int i]
{
get
{
if ((i >= 0) && (i < students.Length))
{
return students[i];
}
else
{
return null;
}
}
set
{
if ((i >= 0) && (i < students.Length))
{
students[i] = value;
}
}
}
static void Main(string[] args)
{
Student firstStudent;
firstStudent = new Student();
firstStudent.Name = "关羽";
firstStudent.BirthDay = new DateTime(1990, 1, 2);
firstStudent.StudentID = "140407";
Student anotherStudent;
anotherStudent = new Student();
anotherStudent.Name = "张飞";
anotherStudent.BirthDay = new DateTime(1996, 2, 3);
anotherStudent.StudentID = "123123";
//Console.WriteLine("{0}号学生{1}出生日期是:{2}",firstStudent.StudentID,firstStudent.Name,firstStudent.BrithDay);
//Console.WriteLine("{0}号学生{1}出生日期是:{2}",anotherStudent.StudentID,anotherStudent.Name,anotherStudent.BirthDay);
StudentClass firstStudentClass = new StudentClass();
firstStudentClass[0] = firstStudent;
firstStudentClass[1] = anotherStudent;
Student getedStudent;
getedStudent = firstStudentClass[1];
Console.WriteLine("{0} 号学生{1}出生日期:{2}", getedStudent.StudentID, getedStudent.Name,
getedStudent.BirthDay);
Console.WriteLine("{0} 号学生{1}出生日期:{2}", getedStudent.StudentID, getedStudent.Name,
getedStudent.BirthDay);
Console.ReadLine();
}
}
} 展开
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Class
{
public class StudentClass
{
private Student[] students = new Student[35];
public Student this[int i]
{
get
{
if ((i >= 0) && (i < students.Length))
{
return students[i];
}
else
{
return null;
}
}
set
{
if ((i >= 0) && (i < students.Length))
{
students[i] = value;
}
}
}
static void Main(string[] args)
{
Student firstStudent;
firstStudent = new Student();
firstStudent.Name = "关羽";
firstStudent.BirthDay = new DateTime(1990, 1, 2);
firstStudent.StudentID = "140407";
Student anotherStudent;
anotherStudent = new Student();
anotherStudent.Name = "张飞";
anotherStudent.BirthDay = new DateTime(1996, 2, 3);
anotherStudent.StudentID = "123123";
//Console.WriteLine("{0}号学生{1}出生日期是:{2}",firstStudent.StudentID,firstStudent.Name,firstStudent.BrithDay);
//Console.WriteLine("{0}号学生{1}出生日期是:{2}",anotherStudent.StudentID,anotherStudent.Name,anotherStudent.BirthDay);
StudentClass firstStudentClass = new StudentClass();
firstStudentClass[0] = firstStudent;
firstStudentClass[1] = anotherStudent;
Student getedStudent;
getedStudent = firstStudentClass[1];
Console.WriteLine("{0} 号学生{1}出生日期:{2}", getedStudent.StudentID, getedStudent.Name,
getedStudent.BirthDay);
Console.WriteLine("{0} 号学生{1}出生日期:{2}", getedStudent.StudentID, getedStudent.Name,
getedStudent.BirthDay);
Console.ReadLine();
}
}
} 展开
6个回答
展开全部
Student firstStudent;
firstStudent = new Student
你这个Student 从哪里来的????
C#里面有这个明明空间吗???
还是他是一个你自己设计的,如果是你自己设计的话
在最上面加上一句“using 工程名称.....Student”
这样应该就没问题了、
firstStudent = new Student
你这个Student 从哪里来的????
C#里面有这个明明空间吗???
还是他是一个你自己设计的,如果是你自己设计的话
在最上面加上一句“using 工程名称.....Student”
这样应该就没问题了、
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
展开全部
你写的很乱 。。。 建议这样写:
class student
{
名字 出生日期 ID
}
Student firstStudent;
firstStudent = new Student();
firstStudent.Name = "关羽";
firstStudent.BirthDay = new DateTime(1990, 1, 2);
firstStudent.StudentID = "140407";
Student anotherStudent;
anotherStudent = new Student();
anotherStudent.Name = "张飞";
anotherStudent.BirthDay = new DateTime(1996, 2, 3);
anotherStudent.StudentID = "123123";
Console.WriteLine("{0} 号学生{1}出生日期:{2}", firstStudent .StudentID, firstStudent .Name,
firstStudent .BirthDay);
不知道写的怎么样,你可以参考下
class student
{
名字 出生日期 ID
}
Student firstStudent;
firstStudent = new Student();
firstStudent.Name = "关羽";
firstStudent.BirthDay = new DateTime(1990, 1, 2);
firstStudent.StudentID = "140407";
Student anotherStudent;
anotherStudent = new Student();
anotherStudent.Name = "张飞";
anotherStudent.BirthDay = new DateTime(1996, 2, 3);
anotherStudent.StudentID = "123123";
Console.WriteLine("{0} 号学生{1}出生日期:{2}", firstStudent .StudentID, firstStudent .Name,
firstStudent .BirthDay);
不知道写的怎么样,你可以参考下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你要定义一个Student类,里面包含Name、BirthDay、StudentID 属性
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-08-13
展开全部
凑数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有student类
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询