I have an anonymous type object that I receive as a dynamic from a method I would like to check in a property exists on that object.
.... var settings = new
public static bool HasProperty(dynamic obj, string name) { Type objType = obj.GetType(); if (objType == typeof(ExpandoObject)) { return ((IDictionary)obj).ContainsKey(name); } return objType.GetProperty(name) != null; }