Clear Method in C# LinkedList

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

704 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 void Main() {       int [] num = {30, 65, 80, 95, 110, 135};       LinkedList list = new LinkedList(num);       foreach (var n in list) {          Console.WriteLine(n);       }       // clear       list.Clear();       Console.WriteLine("No node in the LinkedList now...");       foreach (var n in list) {          Console.WriteLine(n);       }    } }Output30 65 80 95 110 135 No node in the LinkedList now...

Find Non-Whitespace Character Using JavaScript Regular Expression

Daniol Thomas
Updated on 23-Jun-2020 07:49:31

458 Views

To find a non-whitespace character, use the following −\SExampleYou can try to run the following code to find non-whitespace character −        JavaScript Regular Expression                        var myStr = "100% Responsive!";          var reg = /\S/g;          var match = myStr.match(reg);                    document.write(match);          

C# Convert ToInt32 Method

George John
Updated on 23-Jun-2020 07:49:14

780 Views

Use Convert.ToInt32 method to convert text to an integer.Firstly, set a string.string str = "12";Now, use the Convert.ToInt32() method the above string to number.Convert.ToInt32(str);Let us see the complete example.Example Live Demousing System; class Program {    static void Main() {       string str = "12";       Console.WriteLine("String: "+str);       int n = Convert.ToInt32(str);       Console.WriteLine("Number: "+n);    } }OutputString: 12 Number: 12

Implicit Conversion from uint64 to Decimal in C#

Samual Sam
Updated on 23-Jun-2020 07:48:53

423 Views

The ulong type represents a 64-bit unsigned integer i.e. UInt64.To implicitly convert a 64-bit unsigned integer to a Decimal, firstly set UInt64 value.ulong val = ulong.MaxValue;To convert ulong to decimal, assign the value.decimal dec; dec = val;Let us see the above example.Example Live Demousing System; public class Demo {    public static void Main() {       ulong val = ulong.MaxValue;       decimal dec;       Console.WriteLine("Implicit conversion from Ulong to Decimal");       dec = val;       Console.WriteLine("Decimal : "+dec);    } }OutputImplicit conversion from Ulong to Decimal Decimal : 18446744073709551615

LinkedList AddAfter Method in C#

Chandu yadav
Updated on 23-Jun-2020 07:48:28

1K+ Views

Set a LinkedList.int [] num = {1, 2, 3, 4, 5}; LinkedList list = new LinkedList(num);Now add a node at the end using AddLast() method.var newNode = list.AddLast(20);To add a node after the above added node, use the AddAfter() method.list.AddAfter(newNode, 30);Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       int [] num = {1, 2, 3, 4, 5};       LinkedList list = new LinkedList(num);       foreach (var n in list) {          Console.WriteLine(n);       }       // adding a node at the ... Read More

C# Program to Skip Specified Number of Elements in an Array

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

629 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 {    public static void Main() {       int[] points = { 210, 250, 300, 350, 420};       Console.WriteLine("Initial array...");           foreach (int res in points)       Console.WriteLine(res);       IEnumerable skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);       Console.WriteLine("Skipped 3 elements...");       foreach (int res in skipEle)       Console.WriteLine(res);    } }OutputInitial array... 210 250 300 350 420 Skipped 3 elements... 250 210

LinkedList Remove Method in C#

Samual Sam
Updated on 23-Jun-2020 07:47:23

2K+ Views

Use the Remove() method to remove the first occurrence of a node in a LinkedList.Firstly, let us set a LinkedList with integer elements.int [] num = {2, 5, 7, 15}; LinkedList list = new LinkedList(num);Now, let’s say you need to remove node with element 7. For that, use the Remove() method.list.Remove(7);Let us see the complete code.Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       int [] num = {2, 5, 7, 15};       LinkedList list = new LinkedList(num);       foreach (var n in list) {         ... Read More

Check If a Node Is in a Linked List in C#

Arjun Thakur
Updated on 23-Jun-2020 07:46:48

155 Views

Use the Contains() method to check whether a node is a LinkedList or not.Here is our LinkedList.string [] students = {"Beth", "Jennifer", "Amy", "Vera"}; LinkedList list = new LinkedList(students);Now, to check whether the node “Amy” is in the list or not, we will use the Contains() method as shown below −list.Contains("Amy")The method will return a Boolean value i.e. True in this case.Let us see the complete code.Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       string [] students = {"Beth", "Jennifer", "Amy", "Vera"};       LinkedList list = new LinkedList(students);     ... Read More

Convert String to Lowercase Letters in JavaScript

Lakshmi Srinivas
Updated on 23-Jun-2020 07:46:38

170 Views

To convert a string to lowercase letters in JavaScript, use the toLocaleLowerCase() method.ExampleYou can try to run the following code to learn how to work with toLocaleLowerCase() method in JavaScript −Live Demo                    var a = "WELCOME!";          document.write(a.toLocaleLowerCase());          

Convert ToInt64 Method in C#

Ankith Reddy
Updated on 23-Jun-2020 07:46:10

642 Views

Convert a specified value to a 64-bit signed integer using Convert.ToInt64 Method.Let us take a double value.double doubleNum = 193.834;Now, convert it to Int64 i.e. long.long res; res = Convert.ToInt32(doubleNum);Example Live Demousing System; public class Demo {    public static void Main() {       double doubleNum = 193.834;       long res;       res = Convert.ToInt32(doubleNum);       Console.WriteLine("Converted {0} to {1}", doubleNum, res);    } }OutputConverted 193.834 to 194

Advertisements