using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace P6_6{ public class SpecialEventSample { static void Main() { BookStore store = new BookStore(); Customer[] cs = new Customer[3]; cs[0]=new Customer("李明","计算机"); cs[1]=new Customer("赵丽","英语"); cs[2]=new Customer("tom","计算机"); for (int i = 0; i < 3; i++) cs[i].Register(store); store.NewBook("数据结构和算法", "计算机"); store.NewBook("国家地理杂志", "英语");
} } public class BookEventArgs : EventArgs { public string BookName; public string BookTpye; public BookEventArgs(string name,string type) { BookName = name; BookTpye = type; } } public class Customer { private string m_name; private string m_type;
public Customer(string name, string type) { m_name = name; m_type = type; } public void Register(BookStore store) { store.OnNewBook+=new EventHandler(store_OnNewBook); } void store_OnNewBook(object sender, EventArgs e) { BookEventArgs be = (BookEventArgs)e; if (be.BookTpye == m_type) Console.WriteLine("{0}您好:我店新到新书{1}", m_name, be.BookName); } } public class BookStore { public void NewBook(string bookName, string bookType) { BookEventArgs e = new BookEventArgs(bookName, bookType); OnNewBook(this, e); } public event EventHandler OnNewBook; }
}倒数第2行 OnNewBook(this, e); 里的This是什么意思?
C#小程序问题
答案:3 悬赏:40 手机版
解决时间 2021-07-19 13:40
- 提问者网友:萌卜娃娃
- 2021-07-19 01:56
最佳答案
- 五星知识达人网友:我住北渡口
- 2021-07-19 03:15
指的你当前Console.WriteLine所用的控件
比如你有个<input id="ttx1" runet="server" name="ttx1" onclick="save(this)">
比如你有个<input id="ttx1" runet="server" name="ttx1" onclick="save(this)">
全部回答
- 1楼网友:有你哪都是故乡
- 2021-07-19 04:32
简历
- 2楼网友:底特律间谍
- 2021-07-19 03:58
加入一个事件
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯