Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Mwzad66
- {
- class Program
- {
- static void Main(string[] args)
- {
- IEnumerable<int> aa = new IEnumerable();
- }
- }
- public static class IenumerableExtend
- {
- public static bool IsEmpty<T>(this IEnumerable<T> input)
- {
- return input != null && input.Any();
- }
- public static void Mean(this IEnumerable<int> input)
- {
- //
- }
- public static void MeanLength(this IEnumerable<string> input)
- {
- //
- }
- }
- class Example : IEnumerable<string>
- {
- List<string> _elements;
- public Example(string[] array)
- {
- this._elements = new List<string>(array);
- }
- IEnumerator<string> IEnumerable<string>.GetEnumerator()
- {
- //Console.WriteLine("HERE");
- return this._elements.GetEnumerator();
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this._elements.GetEnumerator();
- }
- }
- class Program
- {
- static void Main()
- {
- Example example = new Example(
- new string[] { "cat", "dog", "bird" });
- // The foreach-loop calls the generic GetEnumerator method.
- // ... It then uses the List's Enumerator.
- foreach (string element in example)
- {
- Console.WriteLine(element);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement