Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9095683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:40:02+00:00 2026-06-16T23:40:02+00:00

I am trying to implement Singly Linked List. I am not able to compile

  • 0

I am trying to implement Singly Linked List. I am not able to compile the following code. I have removed lot of unnecessary code which is not relevant for this question from the below snippet:

public class SinglyLinkedList<T>
{
    public SinglyLinkedList()
    {
    }

    private SinglyNode<T> _head = null;

    private class SinglyNode<T>
    {
        public T Data { get; set; }
        public SinglyNode<T> Next { get; set; }
    }

    private class Enumerator<T>
    {
        public Enumerator(SinglyLinkedList<T> list)
        {
            _list = list; //#1
            _head = list._head; //#2
        }

        private SinglyLinkedList<T> _list = null;
        private SinglyNode<T> _head = null;
    }
}

The statement marked #2 is failing with the error – Cannot implicitly convert type 'SinglyLinkedList<T>.SinglyNode<T>' to 'SinglyLinkedList<T>.SinglyNode<T> Program.cs

The statement marked #1 is semantically similar to #2 and it is compiling. What is stopping the program to compile? Are there any genercis + inner classes related rules that are causing the above code to not compile?

Please make a note that the above code snippet is part of my learning by reinventing the wheel and is not a production code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:40:04+00:00Added an answer on June 16, 2026 at 11:40 pm

    The inner classes each declare their own completely different T.

    Just remove the T from the inner classes and all will be well:

    public class SinglyLinkedList<T>
    {
        public SinglyLinkedList()
        {
        }
    
        private SinglyNode _head = null;
    
        private class SinglyNode
        {
            public T Data { get; set; }
            public SinglyNode Next { get; set; }
        }
    
        private class Enumerator
        {
            public Enumerator(SinglyLinkedList<T> list)
            {
                _list = list; //#1
                _head = list._head; //#2
            }
    
            private SinglyLinkedList<T> _list = null;
            private SinglyNode _head = null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a simple singly linked list of integers which are
I am trying to implement a singly linked list in C. A common implementation
I am trying to sort a singly linked list which has been created and
Possible Duplicate: Reverse a singly linked list reverse a linked list? I have been
Good evening I'm trying to implement a single linked list by myself and I've
I'm trying to implement a stack in C using singly linked lists, it all
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
Trying to implement 3-layer (not: tier, I just want to separate my project logically,
Following is my implementation of queue using linked list.I am totally new to data
Im trying to implement multi-threading in my application that makes a lot of float

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.