Arjun Thakur has Published 1109 Articles

The "#" custom specifier in C#

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:50:10

148 Views

The "#" custom format specifier works as a digit-placeholder symbol.If the value to be formatted has a digit in the position where the "#" symbol appears in the format string, then that digit is copied to the resultant string.We have set a double type here.double d; d = 4.2;Now, let ... Read More

C# Any Method

Arjun Thakur

Arjun Thakur

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

8K+ Views

The Any method checks whether any of the element in a sequence satisfy a specific condition or not.If any element satisfy the condition, true is returned.Let us see an example.int[] arr = {5, 7, 10, 12, 15, 18, 20};Now, using Any() method, we will check whether any of the element ... Read More

Represent Int64 as a Octal string in C#

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:42:28

141 Views

To reprsent Int64 as a Octal string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e. 8 for Octal.Int64 represents a 64-bit signed integer.Firstly, set an Int64 variable.long val = 986766;Now, convert it to octal string by including 8 as the second ... Read More

Get rank of a three-dimensional array in C#

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 08:39:23

102 Views

To get the rank of a three-dimensional array, use the Rank property.Set a three-dimensional array.int[,,] arr = new int[3,4,5]Now get the rank.arr.RankLet us see the complete code.Exampleusing System; class Program {    static void Main() {       int[,,] arr = new int[3,4,5]       Console.WriteLine("Dimensions of Array : " + arr.Rank);    } }

C# Queryable SkipWhile() Method

Arjun Thakur

Arjun Thakur

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

105 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

240 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

734 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

3K+ 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

373 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

214 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

Advertisements