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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -