0
C# Stack error
I'm trying to replicate this example from the C# course Generics: Queue<int> q = new Queue<int>(); q.Enqueue(5); q.Enqueue(10); q.Enqueue(15); Console.Write("Queue: "); foreach (int i in q) Console.Write(i + " "); // 5 10 15 And I have the following error: -foreach statement cannot operate on variables of type 'program.Stack<int>' because 'Program.Stack<int>' does not contain a public instance definition for 'GetEnumerator'-
2 Answers
0
U need PUBLIC variables. Define them as public, perhaps it'll get over your problem, i hope.
0
Do you have?
using System.Collections.Generic;