技术开发 频道

C# Winform操作数据库的MVC模式样例代码

【IT168技术文档】

using System;

 namespace MVC

 {

 public class Book

 {

 // declare a delegate for the bookpricechanged event

 public delegate void BookPriceChangedHandler(objectsender,

 BookPriceChangedEventArgs e);

 // declare the bookpricechanged event using the bookpricechangeddelegate

 public event BookPriceChangedHandlerBookPriceChanged;

 // instance variable for book price

 object _bookPrice;

 // property for book price

 public object BookPrice

 {

 set

 {

 // set the instance variable

 _bookPrice=value;

 // the price changed so fire the event!

 OnBookPriceChanged();

 }

 }

 // method to fire price canged event delegate with proper name

 // this is the method our observers should be implenting!

 protected void OnBookPriceChanged()

 {

 BookPriceChanged(this, new BookPriceChangedEventArgs(_bookPrice));

 }

 }

 }
 

 

0
相关文章