用VS2005创建了一个C# windows应用程序 又在该解决方案中新建了一类库 该类库内定义了一个interface接口 怎么使windows窗体访问此接口、、、、?IBankQueue接口代码:
using System;
namespace QueueDs
{
interface IBankQueue:IQueue<int>
{
int GetCallnumber();//获得服务号码
}
}
Form1代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QueueDs;namespace 银行排队叫号系统
{
public partial class Form1 : Form
{
IBankQueue bankQueue = new CSeqBankQueue(100);
CSeqQueue<int> q1 = new CSeqQueue<int>(100);
int Callnumber; public Form1()
{
InitializeComponent();
Form2 f1 = new Form2(this.q1);
Form3 f2 = new Form3(this.q1);
Form4 f3 = new Form4(this.q1);
f1.Show();
f2.Show();
f3.Show();
} private void button1_Click(object sender, EventArgs e)
{ if (!bankQueue.IsFull())
{
Callnumber = bankQueue.GetCallnumber();
textBox1.Text = "你的号码是:" + Callnumber + "号," + "你前面还有" + bankQueue.GetLength() + "位,请耐心等待!";
bankQueue .EnQueue(Callnumber );
q1.EnQueue(Callnumber);
}
else
Console .WriteLine ("现在业务繁忙,请稍后再来!");
Console .WriteLine ();
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
using System;
namespace QueueDs
{
interface IBankQueue:IQueue<int>
{
int GetCallnumber();//获得服务号码
}
}
Form1代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QueueDs;namespace 银行排队叫号系统
{
public partial class Form1 : Form
{
IBankQueue bankQueue = new CSeqBankQueue(100);
CSeqQueue<int> q1 = new CSeqQueue<int>(100);
int Callnumber; public Form1()
{
InitializeComponent();
Form2 f1 = new Form2(this.q1);
Form3 f2 = new Form3(this.q1);
Form4 f3 = new Form4(this.q1);
f1.Show();
f2.Show();
f3.Show();
} private void button1_Click(object sender, EventArgs e)
{ if (!bankQueue.IsFull())
{
Callnumber = bankQueue.GetCallnumber();
textBox1.Text = "你的号码是:" + Callnumber + "号," + "你前面还有" + bankQueue.GetLength() + "位,请耐心等待!";
bankQueue .EnQueue(Callnumber );
q1.EnQueue(Callnumber);
}
else
Console .WriteLine ("现在业务繁忙,请稍后再来!");
Console .WriteLine ();
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
IBankQueue bankQueue = new CSeqBankQueue(100);
CSeqQueue<int> q1 = new CSeqQueue<int>(100);
int Callnumber;
有意义、、、、?
interface IBankQueue:IQueue<int> 相当于 internal interface IBankQueue:IQueue<int>
internal 定义的类型是不能在组件外部访问的,除非明确定义为 public。