karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 61 of 143

Bootstrap panel class

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

Panel components are used when you want to put your DOM component in a box. To get a basic panel, just add class .panel to the element.You can try to run the following code to implement panel class in BootstrapExample           Bootstrap Example                                                       Demo panel                    

Read More

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

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

Count the number of elements in the BitArray class using the Count property.Let us first set our BitArray class −BitArray arr = new BitArray(10);Now use the Count property as shown below −Exampleusing System; using System.Collections; public class Demo {    public static void Main() {       BitArray arr = new BitArray(10);       Console.WriteLine( "Count: {0}", arr.Count );    } }OutputCount: 10

Read More

C# program to check if a Substring is present in a Given String

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

Use the contains() method in C# to check if a substring is in a given string.Let us say the string is −UnitedWithin the string, you need to find the substring “Uni”. For that, use the contains method and use it like the following code snippet −res = str1.Contains(str2);ExampleYou can try to run the following code to find a substring in a string.using System; public class Demo {    public static void Main() {       string str1 = "United", str2 = "Uni";       bool res;       res = str1.Contains(str2);       if (res)   ...

Read More

C# program to check if two matrices are identical

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

To check whether the matrices are identical or not, you need to first check whether the matrixes can be compared or not, since for comparison at least the dimensions of the two matrices should be the same.if (row1 != row2 && col1 != col2) {    Console.Write("Matrices can't be compared:"); }Now, under else condition check for whether the metrics are identical or not. We have also set a flag here −if (row1 != row2 && col1 != col2) {    Console.Write("Matrices can't be compared:"); } else {    Console.Write("Comparison of Matrices: ");    for (i = 0; i < row1; ...

Read More

C# Example for Single Inheritance

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

The following is an example of Single Inheritance in C#. In the example, the base class is Father and declared like the following code snippet −class Father {    public void Display() {       Console.WriteLine("Display");    } }Our derived class is Son and is declared below −class Son : Father {    public void DisplayOne() {       Console.WriteLine("DisplayOne");    } }ExampleThe following is the complete example to implement Single Inheritance in C#.using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyAplication {    class Demo {       static void Main(string[] args) {     ...

Read More

How is an array declared in C#?

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

To declare an array in C#, you can use the following syntax −datatype[ ] Name_of_array;Here, datatype is used to specify the type of elements in the array.[ ] specifies the size of the array.Name_of_array specifies the name of the array.The following is an example −double[ ] balance;Let us see an example in which an array is declared and values are added to it −Exampleusing System; namespace ArrayApplication {    class MyArray {       static void Main(string[] args) {          int [ ] n = new int[10]; /* n is an array of 10 integers ...

Read More

C# Multiple Local Variable Declarations

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

In C#, you can use the comma to declare more than one local variable in a statement. The following displays the same −int a = 20, b = 70, c = 40, d = 90;ExampleLet us see an example in which we are declaring multiple local variables. Below four variable is declared and initialized in the same statement.using System; class Demo {    static void Main() {       int a = 20, b = 70, c = 40, d = 90;       Console.WriteLine("{0} {1} {2} {3}", a, b, c, d);    } }Output20 70 40 90

Read More

ToDictionary method in C#

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

The ToDictionary method is an extension method in C# and converts a collection into Dictionary.Firstly, create a string array −string[] str = new string[] {"Car", "Bus", "Bicycle"};Now, use the Dictionary method to convert a collection to Dictionary −str.ToDictionary(item => item, item => true);Here is the complete code −Exampleusing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       string[] str = new string[] {"Car", "Bus", "Bicycle"};       // key and value under ToDictionary       var d = str.ToDictionary(item => item, item => true);       foreach (var ele in ...

Read More

C# Program to count the number of lines in a file

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

Firstly, create a file using StreamWriter class and add content to it −using (StreamWriter sw = new StreamWriter("hello.txt")) {    sw.WriteLine("This is demo line 1");    sw.WriteLine("This is demo line 2");    sw.WriteLine("This is demo line 3"); }Now use the ReadAllLines() method to read all the lines. With that, the Length property is to be used to get the count of lines −int count = File.ReadAllLines("hello.txt").Length;Here is the complete code −Exampleusing System; using System.Collections.Generic; using System.IO; public class Program {    public static void Main() {       using (StreamWriter sw = new StreamWriter("hello.txt")) {         ...

Read More

C# Program to Check Whether the Entered Number is an Armstrong Number or Not

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

For an Armstrong number, let us say a number has 3 digits, then the sum of cube of its digits is equal to the number itself.For example, 153 is equal to −1³ + 3³ + 5³To check for it using C#, check the value and find its remainder. Here “val” is the number you want to check for Armstrong −for (int i = val; i > 0; i = i / 10) {    rem = i % 10;    sum = sum + rem*rem*rem; }Now compare the addition with the actual value. If it matches, that would mean the ...

Read More
Showing 601–610 of 1,421 articles
« Prev 1 59 60 61 62 63 143 Next »
Advertisements