I need to call a variable that is empty, but how do I do it? I created the following code
public ActionResult Index()
{
cliente cliente;
try
{
cliente = db.cliente.find(id);
//etc
}
catch (Exception ex)
{
var GravaLogErro = new ErroDotNet
{
IDC = cliente != null ? cliente.ClienteId : 0
[Ele fala: User of unasigned local variable 'cliente']
};
GravaLogErro.GravarLog();
}
I did not want to put the client.find out of try / catch until I summarized the logic well, why can not I do a check if it is null? Okay, would I create her like this?
cliente cliente = new cliente();
Would not give problem in find ()?