Answer the question
In order to leave comments, you need to log in
Is it possible to organize shared variables between some methods?
private void SomeCoolrMethod()
{
for (var i = 0; i < 90000; i++)
{
var pamar1 = SetParam1();
var pamar2 = SetParam2();
var pamar3 = SetParam3();
var pamar4 = SetParam4();
var pamar5 = SetParam5();
DoMethod1(param1, param3, param4);
DoMethod2(param1,param2, param4);
DoMethod3(param3,param4,param5);
}
}
Answer the question
In order to leave comments, you need to log in
Why, for example, not to pack it all in a separate class? And do all the work there?
class SomeCool
{
private T pamar1;
private T pamar2;
private T pamar3;
...
private void SomeCoolrMethod()
{
for (var i = 0; i < 90000; i++)
{
var pamar1 = SetParam1();
var pamar2 = SetParam2();
var pamar3 = SetParam3();
var pamar4 = SetParam4();
var pamar5 = SetParam5();
DoMethod1(param1, param3, param4);
DoMethod2(param1, param2, param4);
DoMethod3(param3, param4, param5);
}
}
}
Closure or what?
en.wikipedia.org/wiki/Closure_%28computer_programm...
Func Delegate :
void MyMethod()
{
Func<int> pamar1 = () => 1 * 2;
Func<int> pamar2 = () => 3 * 4;
Func<int> pamar3 = () => 5 * 6;
for (var i = 0; i < 10; ++i)
{
DoMethod(pamar1, pamar2, pamar3);
}
}
void DoMethod(Func<int> pamar1, Func<int> pamar2, Func<int> pamar3)
{
Console.WriteLine(pamar1() * pamar2() * pamar3());
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question