3
I was doing tests, until I received the following error:
Object Reference Not Set To An Instance Of An Object
Researching found that it is the famous NullReferenceException, then I was obliged to do several checks on the code, as I show below, but I believe that doing all these checks is not good in relation to execution time, am I right? If I am there is another way to resolve this or to do these checks in a faster way?
var UrlApi2 = "api/EstoqueExterno/create";
if (ambienteViewModel.EstExt_endereco == null)
   ambienteModel2.EstExt_endereco = "";
else
   ambienteModel2.EstExt_endereco = ambienteViewModel.EstExt_endereco.ToUpper();
   ambienteModel2.EstTp_Codigo = ambienteViewModel.EstTp_Codigo;
if (ambienteViewModel.EstExt_senha == null)
    ambienteModel2.EstExt_senha = "";
else
    ambienteModel2.EstExt_senha = ambienteViewModel.EstExt_senha.ToUpper();
if (ambienteViewModel.EstExt_usuario == null)
    ambienteModel2.EstExt_usuario = "";
else
    ambienteModel2.EstExt_usuario = ambienteViewModel.EstExt_usuario.ToUpper();
Cool, saved me some lines of code kk, thanks
– Jeff Henrique