我喜欢让我的数据库更加动态地插入函数。在不带参数的另一个函数中使用函数的变量?
像这样:
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()参数做到这一点......但我有这么多的领域,并希望它与另一块干净的方式。
我确定有一个正确的方法来干净的开发类似这样的东西。
感谢和问候。
谢谢,认为这是干净的。 – 2009-10-19 08:29:44