-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathexample.cs
More file actions
23 lines (19 loc) · 543 Bytes
/
Copy pathexample.cs
File metadata and controls
23 lines (19 loc) · 543 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public static int Count<TSource>(this IEnumerable<TSource> source)
{
// Comments
if (source == null) throw Error.ArgumentNull("source");
ICollection<TSource> collectionOfT = source as ICollection<TSource>;
if (collectionOfT != null) return collectionOfT.Count;
ICollection collection = source as ICollection;
if (collection != null) return collection.Count;
int count = 0;
using (IEnumerator<TSource> e = source.GetEnumerator()) {
checked {
while (e.MoveNext()) count++;
}
}
/*
multi line comment
*/
return count;
}