ienumerable - C# Why cannot I write custom IEnumerator for my class -
I have a simple class that represents vertex in a graph that is likely to have a tree. Thus, this class looks like this:
class versatx {public versatile origin; Public list & lieutenant; Vertex & gt; children; } If there is no possibility of loops, I can add only one head as a hair multiple times.
Now, I have made a calculator that graphs every head. So that you can
foreach (root vertex in the vertex item) and get every head in the graph. For this, I had to make my class INMEMERABLE {VERTEX} and write the gate anemeter method which grows all the vertextures in a continuous form.
Now, for the purposes of graphging, I want another enumerator, which will return to every edge of the graph, then I can do something like this
foreach (Point [] Item in rootvertex.GetEdges ()) and get all the edges. For this purpose, to avoid confusion, I removed IEnumerable from my classroom and thus implemented two methods
Public Inimatorator & lt; Vertex & gt; GetVertexes () {... code ...} public IEnumerator & lt; Point [] & gt; GetEdges () {... code ...} However, when I try to
foreach (point [] root roottex Items in etetges] ()) This error spits - foreach can not be calculated on the root vertex because the GetEnumerator method is not included in the vertex class.
I tried googling but the weather was not found or not I can not make or make multiple calculators in the same class. First and foremost, you do not have IEnumerable not IEnumerator
as the return result: public IEnumerable & lt; Point [] & gt; GetEdges () {... code ...}
Comments
Post a Comment