I have this code
public class NodeList<T> : Collection<Node<T>>
{
public NodeList() : base() { }
public NodeList(int initialSize)
{ // Add the specified number of items
for (int i = 0; i < initialSize; i++)
base.Items.Add(default(Node<T>));
}
public Node<T> FindByValue(T value)
{ // search the list for the value
foreach (Node<T> node in Items)
if (node.Value.Equals(value)) return node;
// if we reached here, we didn't find a matching node
return null;
}
}
source : http://msdn.microsoft.com/en-US/library/ms379572(v=vs.80).aspx
in visual studio 2010 c# language it gives me an error in
public class NodeList<T> : Collection<Node<T>>
so I change it to ICollection
and then the error jump to base.items , exactly with items
so what is wrong ... it is from msdn.microsoft
akshat goel39 pointsPosted Apr 13, 2014, 1:50 PM EDT
You will need to define the Public class Node<> for this..
You just missed this code from the MSDN link..
public class Node<T> { // Private member-variables private T data; private NodeList<T> neighbors = null; public Node() {} public Node(T data) : this(data, null) {} public Node(T data, NodeList<T> neighbors) { this.data = data; this.neighbors = neighbors; } public T Value { get { return data; } set { data = value; } } protected NodeList<T> Neighbors { get { return neighbors; } set { neighbors = value; } } } }Abdelbasset Barkat3 pointsPosted Apr 13, 2014, 2:13 PM EDT
akshat goel39 pointsPosted Apr 13, 2014, 2:41 PM EDT