what is wrong with this program --- actually I have changed the code too
Code:
// this program is the program on page 112 C#4 Wrox --- 27/11/2012
// it deals with the creation of a generic linkedlist-
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
namespace scratch_pad_2
{
class Program
{
static void Main(string[] args)
{
var list1 = new LinkedList<int>();
list1.AddLast(1);
list1.AddLast(2);
list1.AddLast(3);
foreach (int i in list1)
{
Console.WriteLine(i);
Console.Read();
}
}
}
public class LinkedListNode<int>
{
public LinkedListNode(int value)
{
this.Value = value;
}
public int Value { get; private set; }
public LinkedListNode<int> Next { get; internal set; }
public LinkedListNode<int> Prev { get; internal set; }
}
public class LinkedList<int> : IEnumerable<int> // please see the int is Black , // which should not be.
{
public LinkedListNode<int> First { get; private set; }
public LinkedListNode<int> Last { get; private set; }
public LinkedListNode<int> AddLast(int node)
{
var newNode = new LinkedListNode<int>(node);
if (First == null) { First = newNode; Last = First; }
else
{ Last.Next = newNode; Last = newNode; }
return newNode;
}
public IEnumerator<int> GetEnumerator()
{
LinkedListNode<int> current = First;
while (current != null) { yield return current.Value;
current = current.Next;
}
}
}
}
The error message that comes is
Error 1 Type parameter declaration must be an identifier not a type C:\Users\lenovo\documents\visual studio 2010\Projects\scratch pad 2\Program.cs 28 33 scratch pad 2