1
I have a method that generates me an execption, how to treat this?: I thank you
public string CarregaProdutosDermaClube(string codigoproduto)
{
//consulta os dados
var tbuscar = new BuscaProdutosDermaClubeDAL();
var retorno = tbuscar.ProdutoDermaClube(codigoproduto);
if (string.IsNullOrEmpty(retorno.idproduto))
{
return "0";
}
else
{
return "1";
}
}
if (!string.IsNullOrEmpty(retorno))
return retorno.idproduto; else return 0;
would not be pleasant?– Marconi
Is this code generating Exception? Or do you want it to generate if it is Null? On Else it should not return the contents of var
retorno
? The question is very confusing.– George Wurthmann
You need to check that the return is null first. You could do something like this: return?. idProduct
– Erico Souza
generating Exception
– Harry
Using the VS 2015
– Harry
@ if (!string.Isnullorempty(return)) I will test
– Harry
It didn’t work, if (!string.Isnullorempty(return)) the only one that worked was if (return != null) {}
– Harry