| View previous topic :: View next topic |
| Author |
Message |
ylyael
Joined: 29 Jul 2009 Posts: 1
|
Posted: Fri Aug 07, 2009 9:04 am Post subject: אני צר& |
|
|
יש למישהו את התוכנית שעברנו עליה בכיתה עם ה CarEnumarable וה PrkingLot: IEnumarable ?
וכן את המצגת של Interface ?
אם כן, בבקשה צרפו לכאן או דרך המייל
תודה |
|
| Back to top |
|
 |
sharonshmuelfeldman
Joined: 29 Jul 2009 Posts: 8
|
Posted: Fri Aug 07, 2009 6:57 pm Post subject: i don't have it but there is good sample in msdn and samples |
|
|
//1) define class as ienumerable.
public class Token : IEnumerable
{
private string[] elements;
....
//2) in Token class Write/copy The GetEnumerator methode
public IEnumerator GetEnumerator()
{
return new TokenEnumerator(this);
}
//3) write/copy the IEnumerator class :
private class TokenEnumerator : IEnumerator
{
private int position = -1;
private Tokens t;
public TokenEnumerator(Tokens t)
{
this.t = t;
}
// Declare the MoveNext method required by IEnumerator:
public bool MoveNext()
{
if (position < t.elements.Length - 1)
{
position++;
return true;
}
else
{
return false;
}
}
// Declare the Reset method required by IEnumerator:
public void Reset()
{
position = -1;
}
// Declare the Current property required by IEnumerator:
public object Current
{
get
{
return t.elements[position];
}
}
}
|
|
| Back to top |
|
 |
|