Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by karthikeya Boyini
Page 61 of 143
Bootstrap panel class
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 MoreWhat is the Count property of BitArray class in C#?
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 MoreC# program to check if a Substring is present in a Given String
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 MoreC# program to check if two matrices are identical
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 MoreC# Example for Single Inheritance
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 MoreHow is an array declared in C#?
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 MoreC# Multiple Local Variable Declarations
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 MoreToDictionary method in C#
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 MoreC# Program to count the number of lines in a file
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 MoreC# Program to Check Whether the Entered Number is an Armstrong Number or Not
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