Refactor nested null checking for multiple possible string values
You can just go with :

// Just check both case at the same time
string propertyGuid = propertyList.Where(x =&gt; x.name == "Name" || x.name == "Code").FirstOrDefault()?.ToString();
if (string.IsNullOrEmpty(propertyGuid)) // Same check as you did but written differently
{         
    throw new ArgumentNullException();
}


Then for the future, I guess that you can have Guids on node you don't want to extract. You could have properties on a list or array :

List&lt;string&gt; possibleName = new List&lt;string&gt;() {"Code", "Name"};


And then calling an extract function :

Public static string GetGuid(List&lt;string&gt; possibleName, Whatever propertyList)
{
    string propertyGuid = string.Empty;
    foreach (string name on possibleName)
    {
        propertyGuid = propertyList.Where(x =&gt; x.name == name).FirstOrDefault()?.ToString();
        if (!string.IsNullOrEmpty(propertyGuid))     
        {
             return (propertyGuid);
        }
    }
    throw new ArgumentNullException();
}


Ps : I'd like to add that if propertyList is a NodeList you won't get what you want.