Wrox Programmer Forums
|
C# 4.0 aka C# 2010 General Discussion Discussions about the C# 4.0, C# 4, Visual C# 2010 language and tool not related to any specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 4.0 aka C# 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2012, 02:35 AM
Authorized User
 
Join Date: Sep 2012
Posts: 29
Thanks: 14
Thanked 0 Times in 0 Posts
Default Linked List program on page 112 C#4 Wrox

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
about linked list in c++ indumit18 C++ Programming 0 October 5th, 2011 11:26 AM
Chapter 1 Page 24 Data Grid + Linked List Box not working VS2008 nineismine BOOK: Beginning ASP.NET 2.0 and Databases 0 May 10th, 2009 03:11 PM
Beg.php5, page 112, Cookie sandeepgreaternoida BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 1 May 8th, 2009 03:13 PM
Linked List....!!! amahja56 C++ Programming 4 April 6th, 2004 01:05 PM
Linked Table working very slow with client program Nerijus Access 0 July 7th, 2003 08:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.