Let's set things right. You want to know if you have content in the object, not in the class. Class is just a template .
You can check if the object is null:
if (usuario == null)
Outside this depends on the object. It may be that the object has content is empty, but not null, but it depends on the object's semantics to know how to verify it.
For example, you say that you have a class Usuario
with a property named Ativo
that is bool
you can check:
if (usuario.Ativo)
If it is an array or a list (any enumerable) you can use the Count
you want:
if (lista.Count() > 0)
Assuming that lista
is not null, otherwise it would be better:
if (lista != null && lista.Count > 0)
But it is almost certain that a Usuario
is not a list, and if it is, there is something very wrong there.
If it is a string
, a check may work if it is not empty:
if (texto != "")
or
if(!string.IsNullOrWhiteSpace(texto))
First you need to know what you're dealing with then find a solution.
Although the methods are different, it is essentially the same as Delphi. There is no universal solution.