lundi 12 septembre 2016

nesting three if statements

I would like to check if the condition "_Email" is met the first time and pass the result to the next if statement for another check and then again after that. If _Email is null, I want it to be an empty string for the last check.

Here is the code

    private string _Email;
    public string Email
    {
        get
        {
            if (String.IsNullOrEmpty(_Email))
            {
                _Email = GetEmailAddress();
            }
            else if (_Email.IsEmptyOrNull())
            {
                _Email = User.Current.Preference("Email");
            }
            else if (_Email.IsEmptyOrNull())
            {
                _Email = "";
            }
            return _Email;
        }
    }

This dose not seem to work. I am not sure what I am doing wrong. Please let me know if you need any more info.

Aucun commentaire:

Enregistrer un commentaire