Arjun Thakur has Published 1025 Articles

C# Queryable SkipWhile() Method

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:36:30

152 Views

Bypass elements in an array and return the remaining elements using the SkipWhile() method.The following is our array −int[] marks = { 45, 88, 55, 90, 95, 85 };Now, let’s skip the elements greater than or equal to 60. The condition we have set using Lambda Expression.IEnumerable selMarks = marks.AsQueryable().OrderByDescending(s ... Read More

C# Program to read all the lines one by one in a file

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:27:40

317 Views

Use ReadAllLines() method to read all the lines one by one in a file.Let’s say we have a file “new.txt” with the following lines.One Two ThreeFirstly, set the path of the file to be read.String myPath = "new.txt";Now add it under a string array to fetch the lines on by ... Read More

C# Linq Reverse Method

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:21:46

945 Views

Reverse the elements in an array, using the Reverse method.Here is our character array.char[] ch = { 't', 'i', 'm', 'e' };Now use the Reverse() method with AsQueryable() method to get the reverse.ch.AsQueryable().Reverse();Let us see the complete code.Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {    public ... Read More

AsQueryable() in C#

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:15:40

4K+ Views

AsQueryable() method is used to get an IQueryable reference.Let us see an example to find sum of integer values.Firstly, set an integer array.var arr = new int[] { 100, 200, 300, 400 };Now to find the sum, use the Queryable Sum() and AsQueryable() method.Queryable.Sum(arr.AsQueryable());The following is the complete code.Example Live Demousing ... Read More

LinkedList Contains Method in C#

Arjun Thakur

Arjun Thakur

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

540 Views

Here is our LinkedList.int [] num = {1, 3, 7, 15}; LinkedList list = new LinkedList(num);To check whether the list contains an element or not, use the Contains() method. The following example checks for node 3 in the list.list.Contains(3)Above, returns True since the element is found as shown below −Example Live ... Read More

Year Month ("Y") Format Specifier in C#

Arjun Thakur

Arjun Thakur

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

316 Views

The Year Month format specifier represents a custom date and time format string.It is defined by the DateTimeFormatInfo.YearMonthPattern property.Here is the custom format string.yyyy MMMMExample Live Demousing System; using System.Globalization; class Demo {    static void Main() {       DateTime date = new DateTime(2018, 9, 7, 7, 55, 20); ... Read More

C# Program to check whether a node is a LinkedList or not

Arjun Thakur

Arjun Thakur

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

146 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 ... Read More

LinkedList AddFirst method in C#

Arjun Thakur

Arjun Thakur

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

754 Views

In a Linked List, if you want to add a node at the first position, use AddFirst method.Let’s first set a LinkedList.string [] students = {"Jenifer", "Angelina", "Vera"}; LinkedList list = new LinkedList(students);Now, to add an element as a first node, use AddFirst() method.List.AddFirst(“Natalie”);Example Live Demousing System; using System.Collections.Generic; class Demo ... Read More

C# Program to add a node before the given node in a Linked List

Arjun Thakur

Arjun Thakur

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

259 Views

Declare a LinkedList and add nodes to it.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);Let us add a new node.var newNode = list.AddLast("Kevin");Now, to add a node before the given node, use the AddBefore() method.list.AddBefore(newNode, "Matt");Let us now see the complete code.Example Live Demousing System; ... Read More

C# Program to create a LinkedList

Arjun Thakur

Arjun Thakur

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

304 Views

Firstly, set a string array.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"};Now, add it to the LinkedList.LinkedList list = new LinkedList(students);The above creates a LinkedList and adds node to it.Let us see the complete example.Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {     ... Read More

Advertisements