VS2010 生成序列图实例

今天我用一个非常非常简单的代码实例来体验一下VS2010生成序列图的过程:很简单,希望大家不要拍砖啊:)

例子:声明一个学生类,一个课程类,在主程序中让学生学一个课,就这么简单:)上代码:

课程类:

 using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
     class Course
    {
         public  string CourseName {  getset; }

         public  void ResetCouseName()
        {
             this.CourseName =  " R&S ";
        }
    }
}

学生类:

 using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
     class Student
    {
         public  string StudentName {  getset; }

         public List<Course> SelectedCouses =  new List<Course>();

         public  void AddCourse(Course c)
        {

             this.SelectedCouses.Add(c);
        }

         public  void ResetAllTheCourse()
        {
             foreach ( var item  in SelectedCouses)
            {
                item.ResetCouseName();
            }
        }
    }
}

程序入口:

 using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
     class Program
    {
         static  void Main( string[] args)
        {
            Student s =  new Student();
            Course chineseCourse =  new Course();
            chineseCourse.CourseName =  " Chinese ";

            Course englishCourse =  new Course();
            englishCourse.CourseName =  " english ";

            s.AddCourse(chineseCourse);
            s.AddCourse(englishCourse);

             foreach (Course item  in s.SelectedCouses)
            {
                Console.WriteLine(item.CourseName);   
            }
            Console.Read();
        }
    }
}

最后,如果点击生成序列图

 

然后得到图: 

 

然后结束,至于序列图是什么概念,有图有真相,看图就可以明白怎么玩的了:) 

 

转载于:https://www.cnblogs.com/shineqiujuan/archive/2012/03/04/2379714.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值