Jump to content

IEnumerator in C#

- - - - -

  • Please log in to reply
2 replies to this topic

#1
jashsayani

jashsayani

    Learning Programmer

  • Members
  • PipPipPip
  • 41 posts
Hi,

I have a type Addr with a string and int. I am trying to use IEnumerator of Addr to check for intersections.

I have tried the following:
Addr tmp = someFunction(val); //Returns IEnumerator of Addr
foreach(tmp in anotherIE)
{
     if(tmp = anotherIE)
          // IT INTERSECTS!
}

However, it does not seem to let me do that. How do I accomplish this?

Thanks.

#2
zoranh

zoranh

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
What do you mean by "it does not seem to let me do that". You should employ some work to explain what is the problem before asking others to solve it.

Looking at your code, foreach statement is wrong and if statement is wrong. Foreach statement requires type of the variable, like foreach (Addr tmp in anotherIE). In if statement you're assigning value instead of testing equality.

#3
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
If your class inherits the IEnumurator interface then you have to declarative'ly program the getEnumurator method
http://msdn.microsof...2(v=VS.71).aspx





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users