سلام بر برنامه نویسان عزیز ایران زمین 😉 در این پست کد شمارش Enumerable در c#.net را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد شمارش Enumerable در c#.net :
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
class CountingEnumerable : IEnumerable<int>
{
public IEnumerator<int> GetEnumerator()
{
return new CountingEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
class CountingEnumerator : IEnumerator<int>
{
int current = -1;
public bool MoveNext()
{
current++;
return current < 10;
}
public int Current
{
get { return current; }
}
object IEnumerator.Current
{
get { return Current; }
}
public void Reset()
{
throw new NotSupportedException();
}
public void Dispose()
{
}
}
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
class CountingEnumerable : IEnumerable<int>
{
public IEnumerator<int> GetEnumerator()
{
return new CountingEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
class CountingEnumerator : IEnumerator<int>
{
int current = -1;
public bool MoveNext()
{
current++;
return current < 10;
}
public int Current
{
get { return current; }
}
object IEnumerator.Current
{
get { return Current; }
}
public void Reset()
{
throw new NotSupportedException();
}
public void Dispose()
{
}
}