Karthikeya Boyini has Published 2383 Articles

Convert.ToUInt32 Method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:11:34

218 Views

Convert a specified value to a 32-bit unsigned integer using the Convert.ToUInt32 method.The following is our string.string str = "210";Now, let us convert it to a 32-bit unsigned integer.uint res; res = Convert.ToUInt32(str);Example Live Demousing System; public class Demo {    public static void Main() {       string str ... Read More

C# Math.DivRem Method

karthikeya Boyini

karthikeya Boyini

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

155 Views

Use the Math.DivRem method to calculate the quotient of two numbers and return the remainder.Firstly, set dividend and divisor.// dividend long dividend = 30; // divisor long divisor = 7;Now, use the DivRem method.long quotient = Math.DivRem(dividend, divisor, out rem);Example Live Demousing System; using System.Globalization; class Demo {    static void ... Read More

C# Console.WindowWidth Property

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:05:38

272 Views

The WindowWidth property gets or sets the width of the console window.Declare a variable.int width;Now, get the width of the current window.width = Console.WindowWidth;The following is the complete example.Example Live Demousing System; using System.Numerics; using System.Globalization; class Demo {    static void Main() {       int width;     ... Read More

C# Linq Last() Method

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:03:47

1K+ Views

Get the last element from a sequence using the Linq Last() method.The following is our array.int[] val = { 10, 20, 30, 40 };Now, get the last element.val.AsQueryable().Last();Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       int[] val = { 10, ... Read More

The "0" custom format specifier in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:02:56

2K+ Views

The “0” custom specifier is a zero placeholder.If the value to be formatted has a digit in the position where the zero appears in the format string, the the digit is copied to the resultant string. However, if this doesn’t happen, then a zero appears.Here is our double variable.double d; ... Read More

BinarySearch() method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:01:26

320 Views

BinarySearch() works on a sorted list whether its numeric, alphanumeric or strings. It finds you the index of an element.Let’s say the following is our list.List list = new List(); list.Add(70); list.Add(150); list.Add(220); list.Add(250); list.Add(300);Now to check the index where 250 is placed, use BinarySearch() method.list.BinarySearch(250);Example Live Demousing System; using System.Collections.Generic; ... Read More

C# Linq ElementAt Method

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 08:59:17

224 Views

The ElementAt() method in C# to get elements at specified index position.Firstly, set the string array.string[] str = { "Jack", "Pat", "David"};Now, to get the element at a particular index, use the ElementAt() method as shown in the following example −Example Live Demousing System.IO; using System; using System.Linq; class Program { ... Read More

C# Program to search for a string in an array of strings

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 08:57:43

2K+ Views

Use Linq Contains() method to search for as specific string in an array of strings.string[] arr = { "Bag", "Pen", "Pencil"};Now, add the string in a string variable i.e. the string you want to search.string str = "Pen";Use the Contains() method to search the above string.arr.AsQueryable().Contains(str);Let us see the entire ... Read More

C# OverflowException

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 08:56:02

667 Views

OverflowException is thrown when the parameter value is out of integer ranges.Let us see an example.When we set a value to int.Parse() method that is out of integer range, then OverflowException is thrown as shown below −Example Live Demousing System; class Demo {    static void Main() {       ... Read More

C# Program to convert a Double value to an Int64 value

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 08:47:13

1K+ Views

To convert a Double value to an Int64 value, use the Convert.ToInt64() method.Int64 represents a 64-bit signed integer.Let’s say the following is our double value.double val = 23.951213e12;Now to convert it to Int64.long longVal = Convert.ToInt64(val);Let us see the complete example.Example Live Demousing System; public class Demo {    public static ... Read More

Advertisements