Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 13 of 81

C# program to convert string to long

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 15K+ Views

To convert a string to a long, use the Long.parse method in C# −Firstly, set a string −string str = "6987646475767";Now, convert it to long −long.Parse(str);Here is the complete code −Exampleusing System; using System.Linq; class Demo {    static void Main() {       string str = "6987646475767";       long res = long.Parse(str);       Console.WriteLine(res);    } }Output6987646475767

Read More

Usage of Bootstrap class panel-danger

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 415 Views

The .panel-danger class in Bootstrap is used to indicate danger.You can try to run the following code to implement panel-danger class −Example           Bootstrap Example                                                       Panel title (danger)                                 This is a Basic panel                    

Read More

KeyNotFoundException in C#

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 629 Views

The KeyNotFoundException is thrown when a key you are finding is not available in the Dictionary collection.Let us see an example −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main() {       try {          var dict = new Dictionary() {             {"TV", "Electronics"},             {"Laptop", "Computers"},          };          Console.WriteLine(dict["Pen Drive"]);       }       catch (Exception e) {          Console.WriteLine(e);       }    } }The ...

Read More

What is the Count property of SortedList class in C#?

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 166 Views

Exampleusing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {          SortedList s = new SortedList();          s.Add("S1", "Electronics");          s.Add("S2", "Clothing");          s.Add("S3", "Applicances");          s.Add("S4", "Books");          s.Add("S5", "Accessories");          s.Add("S6", "Musical Instruments");          Console.WriteLine("Count = " + s.Count);       }    } }OutputCount = 6

Read More

Create Dismissal Alerts in Bootstrap

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 408 Views

To create a dismissal alert −Add a basic alert by creating a wrapper and adding a class of .alert and one of the four contextual classes, for example, .alert-success, .alert-info, etc.Also add optional .alert-dismissable to the above class.Add a close button.You can try to run the following code to create dismissal alerts −Example           Bootstrap Example                                                       ×                    Success! Well done its submitted.                                   ×                    Info! Take this info.          

Read More

Why is the Main() method use in C# static?

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 3K+ Views

The Main method states what the class does when executed and instantiates other objects and variables.A main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class.The following shows how to add a Main() method with static −Exampleusing System; namespace Demo {    class HelloWorld {       static void Main(string[] args) {          Console.WriteLine("Bingo!");          Console.ReadKey();       }    } }OutputBingo!As you can see in the ...

Read More

All Method in C#

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 396 Views

The All() extension method is part of the System.Linq namepspace. Using this method, you can check whether all the elements match a certain condition or not.Set an array −int[] arr = { 6, 7, 15, 40, 55 };The following is an example. It checks whether all the elements in the array is greater than and equal to 2 or not −arr.All(element => element > = 2);Here is the complete code −Exampleusing System; using System.Linq; class Program {    static void Main() {       int[] arr = { 6, 7, 15, 40, 55 };       bool res = arr.All(element => element >= 2);       Console.WriteLine(res);    } }OutputTrue

Read More

How to generate the first 100 Odd Numbers using C#?

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 915 Views

To generate first 100 odd numbers, set a for loop from 1 to 100.for(val = 1; val

Read More

Different ways for Integer to String Conversions in C#

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 16K+ Views

The easiest way to convert an integer to a string in C# is using the ToString() method.Let us see an example −int a = 100; string str = a.ToString();Another way is to use Convert.ToString();b = 50; string str2 = Convert.ToString(b); Console.WriteLine(str2);The following is the example showing the different ways to convert integer to string.Exampleusing System; class Program {    static void Main() {       int a, b, c;       a = 10;       string str = a.ToString();       Console.WriteLine(str);       b = 50;       string str2 = Convert.ToString(b);       Console.WriteLine(str2);       c = 100;       string str3 = string.Format("{0}", c);       Console.WriteLine(str3);    } }Output10 50 100

Read More

C# Program to split a string on spaces

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 2K+ Views

Firstly, set a string −string str = "Science and Mathematics";Now use the Split() method to split wherever the spaces occur −str.Split(' ')The following is the complete code −Exampleusing System; using System.Linq; using System.IO; class Program {    static void Main() {       string str = "Science and Mathematics";       Console.WriteLine("String..."+str);       string[] myStr = str.Split(' ');       Console.WriteLine("Splitted String...");       foreach (string ch in myStr) {          Console.WriteLine(ch);       }    } }OutputString... Science and Mathematics Splitted String... Science and Mathematics

Read More
Showing 121–130 of 810 articles
« Prev 1 11 12 13 14 15 81 Next »
Advertisements