필드를 찾고있는 동적 개체의 속성을 반복하고 있습니다 (던지기 전에 존재 여부를 안전하게 평가하는 방법을 알 수 없다) 예외. 당신의 도움이동적 개체에 필드가 있는지 여부를 안전하게 확인하는 방법
건배
foreach (dynamic item in routes_list["mychoices"])
{
// these fields may or may not exist
int strProductId = item["selectedProductId"];
string strProductId = item["selectedProductCode"];
}
감사합니다!
[어떻게하면 동적 테스트하는의 중복 가능성 속성을 사용할 수 있습니다] (http://stackoverflow.com/questions/2998954/dynamic-how-to-test-if-a-property-is-available) –
왜 foreach (동적 항목 개미 그냥 사용하려고 var –
이것은 가장 좋은 대답입니다 http://stackoverflow.com/questions/2839598/how-to-detect-if-a-property-exists-on-a-dynamic-object-in-c – Ehsan