karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 64 of 143

Group by Operator in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 209 Views

Use the group by the operator in C# to separate the results of an expression into parts.Let’s say the following is our array −int[] a = { 5, 10, 15, 20, 25, 30 };Now, using Group by and orderby, we will find the elements greater than 20 −var check = from element in a orderby element group element by chkGreater(element);The following is the complete code −Exampleusing System; using System.Linq; class Demo {    static void Main() {       int[] a = { 5, 10, 15, 20, 25, 30 };       var check = from element in ...

Read More

How to iterate any Map in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 2K+ Views

C# has no built-in Math type. For the same, use a Dictionary.Firstly, create a Dictionary −Dictionary d = new Dictionary(); d.Add("keyboard", 1); d.Add("mouse", 2);Get the keys −var val = d.Keys.ToList();Now, use the foreach loop to iterate over the Map −foreach (var key in val) {    Console.WriteLine(key); }To iterate it, try to run the following code −Exampleusing System; using System.Collections.Generic; using System.Linq; class Program {    static void Main() {       Dictionary d = new Dictionary();       d.Add("keyboard", 1);       d.Add("mouse", 2);       // get keys     ...

Read More

Set warning action for a list item in a list group with Bootstrap

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 153 Views

To set warning action for a list item in a list group, use the .list-group-item-warning classExample           Bootstrap Example                                          Demo                                      A                                        B                                        C                                        D                                

Read More

C# Program to display name of Current Thread

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 292 Views

To display the name of the current thread in C#, use the Name property.Firstly, use the currentThread property to display information about a thread −Thread thread = Thread.CurrentThread;Now use the thread.Name property to display name of the thread −thread.NameExampleLet us see the complete code show current thread’s name in C#.using System; using System.Threading; namespace Demo {    class MyClass {       static void Main(string[] args) {          Thread thread = Thread.CurrentThread;          thread.Name = "My Thread";          Console.WriteLine("Thread Name = {0}", thread.Name);          Console.ReadKey();       }    } }OutputThread Name = My Thread

Read More

How to iterate over a C# dictionary?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 530 Views

Firstly, add elements −IDictionary d = new Dictionary(); d.Add(1,97); d.Add(2,89); d.Add(3,77); d.Add(4,88);Now, get the keys −List myList = new List(d.Keys);To iterate −foreach (int k in myList) {    Console.WriteLine("{0}, {1}", k, d[k]); }The following is an example −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main() {       IDictionary < int, int > d = new Dictionary < int, int > ();       d.Add(1, 97);       d.Add(2, 89);       d.Add(3, 77);       d.Add(4, 88);       List < int > myList = new List < int > (d.Keys);           foreach(int k in myList) {          Console.WriteLine("{0}, {1}", k, d[k]);       }    } }Output1, 97 2, 89 3, 77 4, 88

Read More

Round a number to the nearest even number in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 845 Views

The ToEven property is used with the MidpointRounding Enumeration to round a number to the nearest even number.Declare and initialize a decimal number −decimal val = 25.55M;To round a number to the nearest even number −decimal.Round(val, 0, MidpointRounding.ToEven)Here is the complete code −Exampleusing System; using System.Linq; class Demo {    static void Main() {       decimal val = 25.55M;       Console.WriteLine(decimal.Round(val, 0, MidpointRounding.ToEven));    } }Output26

Read More

Decimal constants in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 3K+ Views

Decimal type has constants to get the minimum and maximum values.Set a decimal value −decimal d = 5.8M;To get the minimum and maximum values of the decimal type, use the following properties −decimal.MaxValue decimal.MinValueHere is the complete code −Exampleusing System; using System.Linq; class Demo {    static void Main() {       decimal d = 5.8M;       Console.WriteLine(d);       Console.WriteLine("Maximum Value: "+decimal.MaxValue);       Console.WriteLine("Maximum Value: "+decimal.MinValue);    } }Output5.8 Maximum Value: 79228162514264337593543950335 Maximum Value: -79228162514264337593543950335

Read More

C# Program to check if a number is Positive, Negative, Odd, Even, Zero

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 2K+ Views

Check for the following conditions −For odd and even, check for the remainder when the number is divided by 2 −// checking for odd/ even if(n % 2 == 0) {    Console.WriteLine("Even"); } else {    Console.WriteLine("Odd"); }For positive, negative and checking whether a number is 0 or not −if (n < 0) { Console.WriteLine("Negative Number!"); } else if(n == 0) {    Console.WriteLine("Zero"); } else {    Console.WriteLine("Positive Number!"); }The following is the complete code:Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(string[] args) {       int n = 19; ...

Read More

Add HTML Content to Bootstrap List Group

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 298 Views

Bootstrap list groups are added using the list-group-item class.Add HTML content to the linked list groups using the following codeExample           Bootstrap Example                                                                      Tutorials                                                            Programming                                        Tutorials on Java, C, C++, etc.                                                            Web Development                                        Tutorials on PHP, HTML5, etc.                                                            Database                                        Tutorials on DBMS, MySQL, DB2, etc.                                                                        Quiz                                                            CAT                                        Quiz for CAT students.                                             NEET             Quiz for NEET students.                    

Read More

C# Program to display temporary file names

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 284 Views

The GetTempPath() method in C# displays temporary file names −Path.GetTempPath();Get the names in a variable and display −string tempFile = Path.GetTempPath();The following is the code −Exampleusing System; using System.IO; class Demo {    static void Main() {       string tempFile = Path.GetTempPath();       Console.WriteLine(tempFile);    } }Output/tmp/

Read More
Showing 631–640 of 1,421 articles
« Prev 1 62 63 64 65 66 143 Next »
Advertisements