Ankith Reddy has Published 1070 Articles

C# Console.WindowTop Property

Ankith Reddy

Ankith Reddy

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

115 Views

The WindowsTop property is used to gets or set the top position of the console window area relative to the screen buffer.Declare an integer variable to get the top position.int top;Now, use the Console.WindowTop property.top = Console.WindowTop;Let us see the complete example.Example Live Demousing System; class Demo {    static void ... Read More

C# Linq FirstorDefault Method

Ankith Reddy

Ankith Reddy

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

18K+ Views

Use the FirstorDefault() method to return the first element of a sequence or a default value if element isn’t there.The following is our empty list −List val = new List { };Now, we cannot display the first element, since it is an empty collection. For that, use the FirstorDefault() method ... Read More

C# Queryable Min Method

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 08:14:53

94 Views

Get the minimum value from a sequence using the Min() method in C#.The following is our list.List list = new List { 1, 2, 3, 4, 5, 6 };Now, use Queryable Min() method to get minimum element.list.AsQueryable().Min();Exampleusing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() { ... Read More

Remove an item from a Hashtable in C#

Ankith Reddy

Ankith Reddy

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

616 Views

The following is our Hashtable −Hashtable h = new Hashtable(); h.Add(1, "Jack"); h.Add(2, "Henry"); h.Add(3, "Ben"); h.Add(4, "Chris");To remove an item, use the Remove() method. Here, we are removing the 3rd element.h.Remove(3);Let us see the complete example.Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() ... Read More

C# Enum Parse Method

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 08:07:12

1K+ Views

The Parse method in Enum converts the string representation of the name or numeric value of enum constants to an equivalent enumerated object.The following is our enumeration.enum Vehicle { Car, Bus, Truck, Motobike };Now, use the GetNames() method in a loop to get the enum values. Parse them using the ... Read More

LinkedList RemoveLast() Method in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:53:04

291 Views

Firstly, declare a LinkedList and add nodes.int [] num = {92, 98, 110, 130, 145, 170, 230, 240, 250, 300, 330}; LinkedList myList = new LinkedList(num);Remove the last node from the LinkedList using the RemoveLast() method.myList.RemoveLast();Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {     ... Read More

Convert.ToInt64 Method in C#

Ankith Reddy

Ankith Reddy

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

440 Views

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

Implicit conversion from Char to Decimal in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:42:22

2K+ Views

To implicitly convert char to a Decimal, firstly set a char.char c = 'p';To convert char to decimal, assign the value.decimal dec; dec = c;Let us see the above example.Example Live Demousing System; public class Demo {    public static void Main() {       char c = 'p';   ... Read More

C# into keyword

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:40:16

85 Views

Set query in a select clause using the into operator.The following is our list with Employee details −IList employee = new List() {    new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} ,    new Employee() { EmpID = 2, EmpName = "Anne", ... Read More

C# Program to get current day of week

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:31:14

13K+ Views

Use DateTime. DayOfWeek property to display the current day of week.DayOfWeek wk = DateTime.Today.DayOfWeek;Now, displaying “wk” would give you the current day of the week.Let us see the complete code to get the current day of week.Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() ... Read More

Advertisements