using System;
class Student
{
int[] mark=new int[5]{89,98,78,85,58};
string[] lessons = { "c#", "java", "c++", "database", "english" };
public Student()
{
Console.WriteLine("begin!");
}//student
private int GetMark(string tLesson)
{
for(int i=0;i<5;i++)
{
if(tLesson==lessons[i])
{
return mark[i];
}//if
if(i==4)
{
return -1;
}//if
}//for
}//getmark
public int this[string lesson]
{
get
{
return (GetMark(lesson));
}//get
}//this
}//Student
class test
{
public static void Main()
{
Student student=new Student();
System.Console.WriteLine("此学生C#的分数为"+student["c#".ToLower()]);
}//main
}//test
总是报
E:\c#\作业\索引\Class1.cs(10): “Student.GetMark(string)” : 并非所有的代码路径都返回值