static does not share values between web users

2

Can I use a static property without sharing values between different users?

More or less like Session ?

Ex: scenario:

private static double valorRetorno;

public CalculaValor()
{
 valorRetorno = //recupera valor do cliente
}

public Imprimi()
{
 Imprimi(valorRetorno); //algo do tipo
}

// logic

Cliente 01 passa pela etapa CalculaValor()
Cliente 01 = valor 25,00
Cliente 01 vai para o setor de Imprimir()
Cliente 02 - entra no Calcular Valor
Cliente 02 = valor 30,00

Cliente 01 - acaba imprimindo o valor 30,00

OBS : If I only remove the property static the print will have valorRetorno as zero.

    
asked by anonymous 26.08.2015 / 20:33

1 answer

2

It is not possible, static just indicates a share of the data for every application. With this modifier the member becomes unique for the class and all instances access it.

I do not know if I understand what you want but the solution in this case seems to be to keep the member as part of the instance. But it should probably be used differently. Only with what is in the question can not know the correct form of use. And I do not know if it's important to the problem.

I will not comment on the fact that I am using a monetary value like double .

    
26.08.2015 / 20:36