Implicit conversion from Int32 to Decimal in C#

George John
Published on 12-Sep-2018 16:13:16
The int type represents a 32-bit signed integer i.e. Int32.To implicitly convert an Int32 to a Decimal, firstly set a Int32 value.int val = 392;To convert Int32 to decimal, assign the value.decimal d; d = val;Let us see another example.Exampleusing System; public class Demo {    public static void Main() ... Read More

LinkedList RemoveFirst() Method in C#

karthikeya Boyini
Published on 12-Sep-2018 16:09:04
Let’s say the following is our LinkedList with integer nodes.int [] num = {29, 40, 67, 89, 198, 234}; LinkedList<int> myList = new LinkedList<int>(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 find the longest string from an array of strings using Lambda Expression

Chandu yadav
Published on 12-Sep-2018 16:09:03
The following is our string array −string[] arr = { "Java", "HTML", "CSS", "JavaScript"};Use the Aggregate method and set a Lambda Expression to find the string with more number of characters.Here, the resultant string should have more number of characters than the initial seed value i.e. “jQuery” here.Example Live Demousing System; ... Read More

Represent Int32 as a Hexadecimal String in C#

Samual Sam
Published on 12-Sep-2018 16:04:44
To represent Int32 as a Hexadecimal string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e. 16 for Hexadecimal.Int32 represents a 32-bit signed integer.Firstly, set an Int32 variable.int val = 9898;Now, convert it to a hexadecimal string by including 16 as the ... Read More

C# program to remove the first occurrence of a node in a Linked List

George John
Published on 12-Sep-2018 16:04:29
The following is our LinkedList list with nodes.string [] students = {"Katie", "Jennifer", "Amy", "Vera"}; LinkedList<string> list = new LinkedList<string>(students);Now let us remove a node with the string element “Vera”.For that, use Remove() method.list.Remove("Vera");Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       string ... Read More

Convert.ToSByte Method in C#

karthikeya Boyini
Published on 12-Sep-2018 15:59:34
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.ToInt64 Method in C#

Ankith Reddy
Published on 12-Sep-2018 15:58:33
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;   ... Read More

LinkedList Remove method in C#

Samual Sam
Published on 12-Sep-2018 15:52:40
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<int> list = new LinkedList<int>(num);Now, let’s say you need to remove node with element 7. For that, use the Remove() ... Read More

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

Arjun Thakur
Published on 12-Sep-2018 15:52:40
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<string> list = new LinkedList<string>(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

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

karthikeya Boyini
Published on 12-Sep-2018 13:17:42
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<int> skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {   ... Read More
Advertisements