В цикле foreach
могут быть использованы объекты, реализующие интерфейс System.Collections.IEnumerable
или System.Collections.Generic.IEnumerable<T>
.
Основные типы объектов:
IEnumerable
или IEnumerable<T>
:
List<T>
Dictionary<TKey, TValue>
HashSet<T>
Queue<T>
и Stack<T>
System.Collections
и System.Collections.Generic
System.String
- итерируются по символам)Пример:
csharp
В цикле foreach
могут быть использованы объекты, реализующие интерфейс System.Collections.IEnumerable
или System.Collections.Generic.IEnumerable<T>
.
Основные типы объектов:
IEnumerable
или IEnumerable<T>
:
List<T>
Dictionary<TKey, TValue>
HashSet<T>
Queue<T>
и Stack<T>
System.Collections
и System.Collections.Generic
System.String
- итерируются по символам)Пример:
csharp
Register or sign in to get access to full answers for all questions from the question bank.