为什么报错了
using System;using System.Collections.Generic;
using System.Linq;
using System.Text; namespace MySchool
{
class Program
{
static void Main(string[] args)
{
//初始化student 类
Student stu = new Student();
Console.WriteLine("请输入姓名:");
stu.name = Console.ReadLine();
Console.WriteLine("请输入年龄:");
stu.age = int.Parse(Console.ReadLine());
Student.Show();
}
}
}
// student 类关键代码
public class Student
{
//姓名
public string name;
//年龄
public int age;
//输出学员信息
public void Show()
{
Console.WriteLine("学员姓名:{0},年龄:{1}", name, age);
}
}
为什么这里报Student.Show();
错误 1 非静态的字段、方法或属性“Student.Show()”要求对象引用 c:\documents and settings\administrator\my documents\visual studio 2010\Projects\MySchool\MySchool\Program.cs 18 13 MySchool
出错了