using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Student zhangfei, liubei;
        public void UpdateForm()
        {
            label3.Text = zhangfei.Name + "have" + zhangfei.Score + "分";
            label4.Text = liubei.Name + "have" + liubei.Score + "分";        }        
        
        
        public Form1()
        {
            InitializeComponent();
            zhangfei = new Student();
            liubei = new Student();
            zhangfei.Name = "zhangfei";
            zhangfei.Score = 100;
            liubei.Name = "liubei";
            liubei.Score = 100;
            UpdateForm;        }        private void button1_Click(object sender, EventArgs e)
        {
            zhangfei.GiveScore(5);
            UpdateForm;
        }        private void button2_Click(object sender, EventArgs e)
        {            liubei.TakeOffScore(3);
            UpdateForm;
        }
    }
}
namespace StudentScore
{
    public class Student
    {
        string Name;
        int Score;        public int GiveScore(int amount)
        {
            if (amount > 0)
            {
                score += amount;
                return amount;
            }
            else
            {
                MessageBox.Show("加分" + amount + "不是一个合理的值");
                return 0;
            }
        }        public int TakeOffScore(int amount)
        {
            if (Score >= amount && amount > 0)
            {
                Score -= amount;
                return amount;            }
            else
            {
                MessageBox.Show("减分" + amount + "不是一个合理的值");
                return 0;
            }        }
    }}

解决方案 »

  1.   

    在Form1中加入Student定义所在的命名空间
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using StudentScore;//此处为加入的命名空间
      

  2.   

    竟然不知道哪错了??? 你不会运行么?直接把你的覆盖掉吧
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            StudentScore.Student zhangfei, liubei;
            public void UpdateForm()
            {
                label3.Text = zhangfei.Name + "have" + zhangfei.Score + "分";
                label4.Text = liubei.Name + "have" + liubei.Score + "分";
            }
            public Form1()
            {
                InitializeComponent();
                zhangfei = new StudentScore.Student();
                liubei = new StudentScore.Student();
                zhangfei.Name = "zhangfei";
                zhangfei.Score = 100;
                liubei.Name = "liubei";
                liubei.Score = 100;
                UpdateForm();        }        private void button1_Click(object sender, EventArgs e)
            {
                zhangfei.GiveScore(5);
                UpdateForm();
            }        private void button2_Click(object sender, EventArgs e)
            {            liubei.TakeOffScore(3);
                UpdateForm();
            }
        }
    }
    namespace StudentScore
    {
        public class Student
        {
            public string Name;
            public int Score;        public int GiveScore(int amount)
            {
                if (amount > 0)
                {
                    Score += amount;
                    return amount;
                }
                else
                {
                    MessageBox.Show("加分" + amount + "不是一个合理的值");
                    return 0;
                }
            }        public int TakeOffScore(int amount)
            {
                if (Score >= amount && amount > 0)
                {
                    Score -= amount;
                    return amount;            }
                else
                {
                    MessageBox.Show("减分" + amount + "不是一个合理的值");
                    return 0;
                }        }
        }}
      

  3.   

     public Form1()
      {
      InitializeComponent();
      zhangfei = new Student();
      liubei = new Student();
      zhangfei.Name = "zhangfei";
      zhangfei.Score = 100;
      liubei.Name = "liubei";
      liubei.Score = 100;
      //UpdateForm;
      UpdateForm();
      }这个写法也太乱了,构造函数干啥的啊,就是初始化自己的变量的嘛,你竟让Form1去初始化Student类的属性
    在Student类中加一个构造函数
    public Student(string name,double score)
    {
      this.name=name;
      this.score=score;
    }
    public Form1()
      {
      InitializeComponent();
      zhangfei = new Student();
      liubei = new Student();
      zhangfei.Name = "zhangfei";
      zhangfei.Score = 100;
      liubei.Name = "liubei";
      liubei.Score = 100;
      //UpdateForm;
      UpdateForm();
      }
    改成
    public Form1()
      {
      InitializeComponent();
      zhangfei = new Student("zhangfei";100);
      liubei = new Student("liubei";100);
      UpdateForm();
      }
    看看是不是简洁了很多
    最后提醒你提高你的结贴率,否则没人会理你的问题