Syntax and Logic errors C#
I am having trouble debugging my code. I found this code in a book example in an incomplete form and containing syntax error and logical errors and I tried my best to debug it and correct these errors. But unfortunately I could not figure out errors even using the debugger. What changes should I need to do in order to correct this code?
namespace Exercise_9
{
class Program
{
static void Main(string[] args)
{
//make some sets
//Note, this is where I make the correction within the code.
//Originally, this was written as Set A = new Set(); and
// Set B = new Set();
//Here is the correction by assigning the set variable
Set A = new Set();
Set B = new Set();
//put some stuff in the sets
Random r = new Random();
for (int i = 0; i < 10; i++)
{
A.addElement(r.Next(4));
B.addElement(r.Next(12));
}
//display each set and the union
Console.WriteLine("A: " + A);
Console.WriteLine("B: " + B);
Console.WriteLine("A union B: " + A.union(B)); //note, I believe this isnt a proper notation.
//display original sets (should be unchanged)
Console.WriteLine("After union operation");
Console.WriteLine("A: " + A);
Console.WriteLine("B: " + B);
}
}
}