lundi 11 février 2019

How to simplify the IF ELSE statement C#?

            if (string.IsNullOrEmpty(member.LastName))
            {
                return $"{member.FirstName}".Trim();
            }
            else
            {
                return $"{member.LastName} {member.FirstName}".Trim();
            }

        else
            if (string.IsNullOrEmpty(member.LastName))
            {
                return $"{member.FirstName}".Trim();
            }
            else
            {
                return $"{member.FirstName} {member.LastName}".Trim();
            }

I need to simplify this statement shorter but im not sure how? Im newbie in this stuff i might need some help on it.. any suggestion?

Aucun commentaire:

Enregistrer un commentaire