Skip to content
InfinityKnow

InfinityKnow

Infinity Knowledge (IK) : Technology, Articles, Topics, Facts or many More.

  • Home
  • Education
    • yttags
    • Make Money
    • Jobs
    • Programming
      • Technology
      • Web Design
      • WEB HOSTING
      • Interview
  • Entertainment
    • pakainfo
    • Sports
    • Tips and Tricks
      • Law
      • Photography
      • Travel
  • Health
    • Insurance
    • Lifestyle
      • Clothing
      • Fashion
      • Food
  • News
    • Insurance
      • Auto Car Insurance
      • Business Insurance
    • Donate
    • California
  • News
    • Political
  • Home Improvement
  • Trading
    • Marketing
    • Top Tranding
    • Business
    • Real Estate
  • Full Form
  • Contact Us
  • Difference between attorney, barrister, lawyer, and solicitor?
    Difference between attorney, barrister, lawyer, and solicitor? Articles
  • Angular Autocomplete multiple Tags value Technology
  • Zindagi shayari Shayari
  • convert generic list to datatable in Asp.Net C#,VB Technology
  • Harry potter quotes Quotes
  • raksha bandhan
    raksha bandhan essay in hindi Stories
  • The USA's Best Mesothelioma Lawyer asbestos exposure attorneys
    The USA’s Best Mesothelioma Lawyer asbestos exposure attorneys Articles
  • Sad shayari in hindi
    Sad shayari in hindi Shayari

C# LinkedList Tutorial with Examples

Posted on September 21, 2018September 21, 2018 By admin No Comments on C# LinkedList Tutorial with Examples

C# LinkedList Tutorial with Examples

Today, We want to share with you LinkedList in C#.Net with example
.In this post we will show you LinkedList in C#.Net with example, hear for LinkedList(T) Class (System.Collections.Generic) we will give you demo and example for implement.In this post, we will learn about Linked List Implementation In C# with an example.

Introduction: LinkedList in C#.Net

In this post, we will learn about LinkedList in C#.Net with example.

Linked List

A linked list is a linear data structure. It is a collection of elements. The element is called as Node.Every element has value(data) and reference of next node. The very first node is called as Head and last element has reference to a null value.

Types of Linked Lists

There are 3 types of linked lists in C#.

1. Singly Linked List :

This type of Linked List has a value(data) and a reference to next node. In this, last node’s next reference will be null.

READ :  AngularJS Timing Events setTimeout Example

2. Doubly Linked List:

This type of Linked List has a data and 2 references, one for next node and another for previous node and last node’s next reference will be null.

3. Circular Linked List:

In the circular linked list, last node’s next reference will be head or first element. The circular linked list can be the singly linked list or doubly linked list.

Advantage of Linked List

The major advantage of the linked list is that it is a dynamic data structure.It can grow and shrink in size we can add a dynamic number of data in a linked list without bothering about the size of the linked list.

Disadvantage of Linked List

The disadvantage of a linked list is that it takes more space than an array. Because it stores a reference of next/previous nodes.

READ :  C# swap two numbers without third variable

Operations in Linked List

  • 1. Add node to last element
  • 2. Add node as fist element
  • 3. Remove node from start
  • 4. Traverse whole linked list

Now Create one Console Application in Visual Studio and write below code in it.

[php]
using System;
using System.Collections;

namespace ConsoleDemo
{
class Program
{
static void Main(string[] args)
{
// LinkedList Demo code
LinkedList _LinkedList = new LinkedList();
_LinkedList.PrintAllNodes();
Console.WriteLine();

_LinkedList.AddAtLast(12);
_LinkedList.AddAtLast(“DotNetK.com”);
_LinkedList.AddAtLast(“Live24u.com”);
_LinkedList.AddAtLast(34);
_LinkedList.PrintAllNodes();
Console.WriteLine();

_LinkedList.AddAtStart(55);
_LinkedList.PrintAllNodes();
Console.WriteLine();

_LinkedList.RemoveFromStart();
_LinkedList.PrintAllNodes();

Console.ReadKey();
}
}

public class LinkedList
{
public LinkedList()
{
head = new Node();
current = head;
}

private Node head;
private Node current;
public int Count;

public void AddAtLast(object data)
{
Node newNode = new Node();
newNode.Value = data;
current.Next = newNode;
current = newNode;
Count++;
}

public void AddAtStart(object data)
{
Node newNode = new Node() { Value = data };
newNode.Next = head.Next;
head.Next = newNode;
Count++;
}

READ :  How to send WhatsApp Messages from PHP

public void RemoveFromStart()
{
if (Count > 0)
{
head.Next = head.Next.Next;
Count–;
}
else
{
Console.WriteLine(“linked list is empty.”);
}
}

public void PrintAllNodes()
{
//Traverse from head
Console.Write(“Head ->”);
Node curr = head;
while (curr.Next != null)
{
curr = curr.Next;
Console.Write(curr.Value);
Console.Write(“->”);
}
Console.Write(“NULL”);
}
}

public class Node
{
public Node Next;
public object Value;
}
}

[/php]

Read :

  • Technology
  • Google Adsense
  • Programming

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about LinkedList in C#.Net with example and full description.I would like to have feedback on my Pakainfo.com blog.Your valuable feedback, question, or comments about this article are always welcome.If you enjoyed and liked this post, don’t forget to share.

Related posts:

  1. Vuejs Simple Navigation Menu vue router-link params
  2. C# HashSet Tutorial with Examples
  3. C# ArrayList Class Tutorial with Examples
  4. vuejs toggle class – vue js v-class – Dynamic Components in Vuejs
Technology, Asp.Net Tags:c# doubly linked list, c# linked list foreach, c# linked list node, c# linked list vs list, linked list c# implementation, linked list c# tutorialspoint, Linked List Implementation In C#, linked list in c# using pointers, LinkedList in C#.Net with example, LinkedList(T) Class (System.Collections.Generic), singly linked list in c#

Post navigation

Previous Post: vuejs-datepicker vuejs datetimepicker – Vuejs Calendar Example
Next Post: Angular get post Method in php MySQLi

Related Posts

  • how to get last inserted id in laravel 6? Technology
  • Laravel Check if the Model has a Relationship Technology
  • Angular Interval Service Example Technology
  • AngularJS Simple Line Charts using JSON
    AngularJS Simple Line Charts using JSON Technology
  • AngularJS AutoComplete Search Dynamic Data using Web API
    AngularJS AutoComplete Search Dynamic Data using Web API Technology
  • PHP Laravel Get current url Example
    PHP Laravel Get current url Example Technology

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Account web hosting (1)
  • AngularJs (277)
  • Articles (143)
  • Asp.Net (49)
  • Astrology (2)
  • Attorney (7)
  • Auto Car Insurance (4)
  • Biography (2)
  • Business (9)
  • Business Insurance (3)
  • California (4)
  • Choose the web hosting (1)
  • Clothing (6)
  • cloud (8)
  • Cloud data storage (2)
  • Credit (1)
  • Dedicated hosting server web (1)
  • Dedicated server web hosting (1)
  • Dedicated web hosting (1)
  • Degree (11)
  • Design (9)
  • Differences shared hosting (1)
  • Donate (2)
  • Education (37)
  • Energy web hosting (1)
  • Entertainment (6)
  • Facts (12)
  • Fashion (3)
  • Finance (3)
  • Food (5)
  • full form (90)
  • Google Adsense (22)
  • Health (20)
  • Home Improvement (5)
  • Insurance (6)
  • Interview (2)
  • Jobs (6)
  • jquery (2)
  • jQuery (2)
  • Laravel (164)
  • Lawyer (4)
  • Lifestyle (6)
  • Loans (6)
  • Make Money (31)
  • Managed dedicated server (1)
  • Managed hosting solution (1)
  • Managed servers (1)
  • Marketing (8)
  • Mortgage (2)
  • Movies (21)
  • MySQL (180)
  • News (5)
  • Photography (1)
  • PHP (250)
  • Programming (18)
  • Quotes (75)
  • Real Estate (2)
  • SEO (9)
  • Shared web hosting (1)
  • Shayari (67)
  • Sports (5)
  • Status (34)
  • Stories (45)
  • suvichar (8)
  • Tech (3)
  • Technology (675)
  • Tips and Tricks (42)
  • Top Tranding (35)
  • Trading (28)
  • Travel (12)
  • Uncategorized (8)
  • VueJs (179)
  • Web Design (2)
  • WEB HOSTING (1)
  • Web hosting company (1)
  • Web hosting really (1)
  • Web hosting windows (1)
  • Which website hosting (1)
  • Wishes (13)
  • wordpress (15)

Categories

AngularJs (277) Articles (143) Asp.Net (49) Attorney (7) Business (9) Clothing (6) cloud (8) Degree (11) Design (9) Education (37) Entertainment (6) Facts (12) Food (5) full form (90) Google Adsense (22) Health (20) Home Improvement (5) Insurance (6) Jobs (6) Laravel (164) Lifestyle (6) Loans (6) Make Money (31) Marketing (8) Movies (21) MySQL (180) News (5) PHP (250) Programming (18) Quotes (75) SEO (9) Shayari (67) Sports (5) Status (34) Stories (45) suvichar (8) Technology (675) Tips and Tricks (42) Top Tranding (35) Trading (28) Travel (12) Uncategorized (8) VueJs (179) Wishes (13) wordpress (15)
  • happy birthday grandfather Stories
  • Laravel 6 get ip address Technology
  • raksha bandhan
    raksha bandhan nibandh Stories
  • Windows 10 Product Keys 100% Working Activation – windows 10 activation key free Technology
  • Vuejs Game Programming – fastest click GAME
    Vuejs Game Programming – fastest click GAME Technology
  • Angular 6 Hello World Application
    Creating Angular 6 Hello World Application Technology
  • Codeigniter Generate Dynamic XML Sitemap
    Codeigniter Generate Dynamic XML Sitemap Technology
  • raksha-bandhan
    rakhi par nibandh Stories

Copyright © 2022 InfinityKnow.

Powered by PressBook News WordPress theme