13,190
社区成员
发帖
与我相关
我的任务
分享
使用委托就可以了:
BLL中:
C# code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace BLL
{
public class Test
{
public delegate void RefreshDelegate(ref string msg);
public void Call(RefreshDelegate d)
{
string msg = string.Empty;
for (int i = 1; i <= 10; i++)
{
msg = string.Format("{0}\r\n", i);
d(ref msg);
}
}
}
}
UI层:
C# code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace CSWin
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void btn_Test_Click(object sender, EventArgs e)
{
BLL.Test test = new BLL.Test();
BLL.Test.RefreshDelegate d = new BLL.Test.RefreshDelegate(Refresh);
test.Call(d);
}
private void Refresh(ref string msg)
{
this.textBox1.Text += msg;
}
}
}
public class A
{
public string Field_1{get;set;}
public int Field_2{get;set;}
public B[ ] Field_3{get;set;}
}
这类失血模型,不但 Model 不可能与数据库引擎关系,也不可能与业务功能操作有关系。