LinkedList AddFirst method in C#

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

Convert.ToInt32 Method in C#

karthikeya Boyini
Published on 12-Sep-2018 12:52:00
Use the Convert.ToInt32() method to convert a specified value to a 32-bit signed integer.Let us take a double variable.double doubleNum = 11.53;Now, we will convert it to Int32 using the Convert.ToInt32 method.int intNum; ntNum = Convert.ToInt32(doubleNum);Example Live Demousing System; public class Demo {    public static void Main() {     ... Read More

C# Program to return a collection with repeated elements

Chandu yadav
Published on 12-Sep-2018 12:48:36
To return a collection with repeated elements in C#, use Enumerable.Repeat method.It is part of System.Linq namespace.Let’s say you need to repeat a number twice, for that set the number and the frequency of repetition.Enumerable.Repeat(50, 2);Now assign it to a variable and display it.Example Live Demousing System; using System.Linq; class Demo ... Read More

C# Program to invert the order of elements in a sequence

Samual Sam
Published on 12-Sep-2018 12:48:04
Set a string.char[] ch = { 'd', 'r', 'i', 'v', 'e' }; Console.Write("String = foreach(char arr in ch) Console.Write(arr);Now, use Queryable Reverse() method to invert the order of elements.IQueryable<char> res = ch.AsQueryable().Reverse();Let us see the complete code.Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static ... Read More

C# Program to create a LinkedList

Arjun Thakur
Published on 12-Sep-2018 12:44:12
Firstly, set a string array.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"};Now, add it to the LinkedList.LinkedList<string> list = new LinkedList<string>(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

C# Program to merge sequences

karthikeya Boyini
Published on 12-Sep-2018 12:43:57
Let’s add two sequences.Integer Array.int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8 };String Array.string[] stringArray = { "Depp", "Cruise", "Pitt", "Clooney", "Sandler", "Affleck", "Tarantino" };Now to merge both the above sequences, use the Zip method.ntArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two);Let us see ... Read More

Different Star Pattern Programs in C#

George John
Published on 12-Sep-2018 12:37:52
Like any other programming languages such as C, C++, Java, we can easily display start pattern programs in C#.Let us see them one by one.Example Live Demousing System.IO; using System; class Program {    static void Main() {       for (int i = 1; i <= 6; ++i) { ... Read More

Convert.ToDateTime Method in C#

Samual Sam
Published on 12-Sep-2018 12:36:18
The Convert.ToDateTime method converts a given value to a DateTime value.The following is my string.string myDateString; myDateString = "09/09/2018";Now, let us convert it using the Convert.ToDateTime() method.DateTime result; result = Convert.ToDateTime(myDateString);Here is the complete example.Example Live Demousing System; public class Demo {    public static void Main() {       ... Read More

Convert.ToChar Method in C#

Chandu yadav
Published on 12-Sep-2018 12:32:20
The Convert.ToChar method is used to convert a specified value to a Unicode integer.We have declared an sbyte variable.sbyte byteVal = 200;Now, use the Convert.ToChar() method to convert the sbyte value to a Unicode integer.charVal = Convert.ToChar(b);Let us see another example.Example Live Demousing System; public class Demo {    public static ... Read More

Difference between TimeSpan Seconds() and TotalSeconds()

karthikeya Boyini
Published on 12-Sep-2018 12:31:40
TimeSpan Seconds() is part of time, whereas TimeSpan TotalSeconds() converts entire time to seconds.Let us first see the TimeSpan Seconds() method.Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0);       ... Read More
Advertisements