【发布时间】:2009-10-19 08:20:29
【问题描述】:
我喜欢用函数让我的数据库更动态地插入。
像这样:
private void setValues() {
string test = "foo";
string test2 = "bar";
}
private void WriteToDB() {
dc dcOfMyDatabase = new dc();
DBTable myTable = DbTable() {
field1 = test; // values of other function
field2 = test2; // values of other function
}
}
private void doAll() {
setValues();
WriteToDB();
}
当然,我可以使用 WriteToDB() 中的参数来做到这一点……但我有这么多字段,希望它可以用另一种干净的方式工作。
我确信有一种正确的方法可以干净地开发这样的东西。
感谢和问候。
【问题讨论】:
标签: c# asp.net variables function