In the code below, the line
foreach (PSObject d in (PSObject[])result.Members["description"].Value)
is causing an exception. "Object reference not set to an instance of an object." Looking through the debugger, that is because there is no element at ["description"]. How can I check to see if an element is there before attempting to get it?
foreach (PSObject result in psInstance.Invoke())
            {
                if (result != null)
                {
                    string pName = result.Members["name"].Value.ToString();
                    string pType = result.Members["parameterValue"].Value.ToString();
                    StringBuilder paramDesc = new StringBuilder();
                    foreach (PSObject d in (PSObject[])result.Members["description"].Value)
                    {
                        paramDesc.Append(d.Members["Text"].Value);
                    }
                    PsAdtParameter param = new PsAdtParameter();
                    param.Description = paramDesc.ToString();
                    param.Name = pName;
                    param.Type = pType;
                    command.Parameters.Add(param);
                }
            }
I know how to check for null. But trying this doesn't work:
foreach (PSObject d in (PSObject[])result.Members["description"].Value)
{
    if(d != null)
    {
        //Do something
Because the reference to Members["description"] causes the exception. Do I have to loop through the array and check each Name property to see if it is "Description"?
 
     
     
     
    