Please provide your inputs on the below scenario,
For instance, I have a collection - Dictionary which has some 10 items. Each item can be a simple key value pair / the value can again be a any of the following like Hashtable[] / String[] / DataTable / a custom type / a custom type[] / Dictionary / Array List etc.
I should iterate the collection until the value is a simple key value pair indefinitely. Please let me know the best way to achieve this.
This may be enough for you
foreach (KeyValuePair<int, object> pair in dictionary)
{
if (pair.Value.GetType().IsValueType || pair.Value is string)
{
// do something
break;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.