Observer 观察者模式 (HeadFirst设计模式 c#)
Observer.cs
using System;
using System.Text;
using System.Collections.Generic;
namespace Observer
{
public interface ISubject
{
void RegisterObserver(IOvserver o);
void RemoveObserver(IOvserver o);
void NotifyObserver();
}
public interface IOvserver
{
void update(float temp, float humidity, float pressure);
}
public interface IDisplayElement
{
void display();
}
public class WeatherData:ISubject
{
private List<IOvserver> obList;
private float temperature;
private float humidity;
private float pressure;
public WeatherData()
{
obList = new List<IOvserver>();
}
public void RegisterObserver(IOvserver o)
{
obList.Add(o);
}
public void RemoveObserver(IOvserver o)
{
if (obList.IndexOf(o) >= 0)
{
&nb
相关文档:
上篇文章中说到什么是 Cache对象,如何在ASP.NET中使用 Cache对象。下面我们来说说如何在ASP.NET中删除项。
ASP.NET Cache 对象设计用于保证它并不使用过多的服务器内存。结果是,当用内存变得缺乏时,Cache对象自动删除最少被使用的项。你可以通过定义时间限制、依赖项、以及项
在Cache对象中的优先级来影响 Cache对象保 ......
1 using System;
2 using System.Collections;
3 using System.Configuration;
4 using System.Data;
5 using System.Linq;
6 using System.Web;
7 using System.Web.Security;
8 using&nbs ......
一、Access从Excel中导入数据
1.用到的Excel表的格式及内容
实现
OleDbConnection con = new OleDbConnection();
try
{
OpenFileDialog openFile = new OpenFileDialog();//打开文件对话框。
openFile.Filter = ("Excel 文件(*.xls)|*.xls") ......
方法一:遍历正在有相同名字运行的例程
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DHPSS.COM
{
/// <summary>
/// c#程序只运行一次,C#例程只运行一次
/// http://blog.csdn.net/nnsw ......
一.类与结构的示例比较:
结构示例:
public struct Person
{
string Name;
int height;
int weight
public bool overWeight()
{
//implement something
}
}
类示例:
public class TestTime
{
int hours;
int minutes;
int seconds;
public void passtime()
{
//implementation ......