c# - Use Variable of a function in another function without parameters? -


I want to insert more dynamically with my database function.

Like it:

  Private Zero Set Value () {string test = "foo"; String test2 = "bar"; } Private Zero WriteToDB () {DC dcOfMyDatabase = new DC (); DBTable myTable = DbTable () {field1 = test; // Other function field2 = test2; // other function values}} private zero () {setValues ​​(); WriteToDB (); }  

Of course I can do it with parameters in WriteToDB () ... but I have so many fields and hope it works in a cleaner way.

Im

Thanks and best wishes.

You can promote them in class members or properties:

 < Code> string test; Private Zero Set Value () {test = "foo"; }  

or:

  string test {get; Setting;}  

You should read about object-oriented design and programming - it will help you organize your code more logically.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -