[b]在C#中怎樣調用接口方法[/b]
在C#中怎樣調用接口方法
工程1、即接口工程ITest,內容如下:
namespace ITest
{
public interface Interface1
{
string ReturnString();
}
}
工程2、即實踐方法工程BLLTest,內容如下:(在此工程中引用ITest.dll)
using ITest;
namespace BLLTest
{
public class BLLTest:Interface1
{
public string ReturnString()
{
return "OK";
}
}
}
工程3、即用戶界面工程UITest,內容如下:(在此工程中引用了ITest.dll)
using ITest;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//不知怎么寫了,謝謝幫助
ClsForm1.Interface1 a = ........
MessageBox.Show(ClsForm1.Interface1.ReturnString());
}
}
}
[解决办法]