Karthikeya Boyini has Published 2383 Articles

LinkedList RemoveFirst() Method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:55:13

427 Views

Let’s say the following is our LinkedList with integer nodes.int [] num = {29, 40, 67, 89, 198, 234}; LinkedList myList = new LinkedList(num);Now, if you want to remove the first element from the list, then use the RemoveFirst() method.myList.RemoveFirst();Example Live Demousing System; using System.Collections.Generic; class Demo {    static void ... Read More

C# Program to remove a node at the end of the Linked List

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:52:28

109 Views

The following is our LinkedList.string [] employees = {"Patrick", "Robert", "John", "Jacob", "Jamie"}; LinkedList list = new LinkedList(employees);Now, let’s say you need to remove the last node i.e. “Jamie”. For that, use the RemoveLast() method.list.RemoveLast();Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       ... Read More

LinkedList Clear() Method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:50:00

562 Views

Use the Clear() method to clear a LinkedList. This will remove all the nodes from the LinkedList.Let’s say the following is our LinkedList −int [] num = {30, 65, 80, 95, 110, 135}; LinkedList list = new LinkedList(num);To clear the LinkedList.list.Clear();Example Live Demousing System; using System.Collections.Generic; class Demo {    static ... Read More

C# Program to skip a specified number of elements of an array

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:47:50

459 Views

The following is our array −int[] points = { 210, 250, 300, 350, 420};Use skip() method to skip elements. Add the number as an argument that displays the number of elements to be returned.IEnumerable skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {   ... Read More

Convert.ToSByte Method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:45:44

236 Views

Convert a specified value to an 8-bit signed integer i.e. SByte.It is a signed 8-bit integer data type which stores value between -128 to 127.Let us see an example. We have a double variable.double doubleNum = -19.9;Now, let us convert it to SByte.sbyte res; res = Convert.ToSByte(doubleNum);Example Live Demousing System; public ... Read More

Convert.ToInt32 Method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:43:49

5K+ Views

Use the Convert.ToInt32() method to convert a specified value to a 32-bit signed integer.Let us take a double variable.double doubleNum = 11.53;Now, we will convert it to Int32 using the Convert.ToInt32 method.int intNum; ntNum = Convert.ToInt32(doubleNum);Example Live Demousing System; public class Demo {    public static void Main() {     ... Read More

C# Program to add a node at the last position in a Linked List

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:41:13

186 Views

Set a LinkedList with nodes.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);Now, use the AddLast() method to add a node at the last position.list.AddLast("Kevin");Here is the complete code with the updated LinkedList.Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() { ... Read More

Difference between TimeSpan Seconds() and TotalSeconds()

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:36:57

3K+ Views

TimeSpan Seconds() is part of time, whereas TimeSpan TotalSeconds() converts entire time to seconds.Let us first see the TimeSpan Seconds() method.Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0);       ... Read More

C# Program to merge sequences

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:32:51

156 Views

Let’s add two sequences.Integer Array.int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8 };String Array.string[] stringArray = { "Depp", "Cruise", "Pitt", "Clooney", "Sandler", "Affleck", "Tarantino" };Now to merge both the above sequences, use the Zip method.ntArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two);Let us see ... Read More

C# Program to check whether the elements of a sequence satisfy a condition or not

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 07:30:47

264 Views

Use All() Method to check whether the elements of a sequence satisfy a condition or not. Even if one of the element do not satisfy the set condition, the All() method returns False.To set conditions, use Lambda Expressions. Below shows a condition to check whether all the elements are greater ... Read More

Advertisements