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 57 of 143
C# program to find the maximum of three numbers
Firstly, let’s set the three numbers −int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50;Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, that would mean the largest number is num1.ExampleYou can try to run the following code to find the maximum of three numbers.using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { int num1, ...
Read MoreC# Program to Create a Thread Pool
For a thread pool, create more than two functions and queue methods for execution.Firstly, create a method like −public void one(object o) { for (int i = 0; i
Read MoreAddition and Concatenation in Java
'+' operator in java can be used to add numbers and concatenate strings. Following rules should be considered.Only numbers as operands then result will be a number.Only strings as operands then result will be a concatenated string.If both numbers and strings as operands, then numbers coming before string will be treated as numbers.If both numbers and strings as operands, then numbers coming after string will be treated as a string.Above rule can be overridden using brackets().ExampleCreate a java class named Tester.Tester.javapublic class Tester { public static void main(String args[]) { //Scenario 1: Only ...
Read MoreC# program to find the sum of digits of a number using Recursion
Let’s say we have set the number for which we will find the sum of digits −int val = 789; Console.WriteLine("Number:", val);The following will find the sum of digits by entering the number and checking it recursively −public int addFunc(int val) { if (val != 0) { return (val % 10 + addFunc(val / 10)); } else { return 0; } }ExampleThe following is our code to find the sum of digits of a number using Recursion in C#.using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class ...
Read MoreWhat does Array.LongLength property of array class do in C#?
The Array.LongLength property gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array.Let’s say your array of long data type is −long[,] arr1= new long[15, 35];Use the LongLength property to get an integer representing the total number of elements in all dimensions of the Array −arr1.LongLengthLet us see an example to implement the Array.LongLength property of array class −Exampleusing System; class Program { static void Main() { long[,] arr1= new long[15, 35]; long len1 = arr1.GetLongLength(0); Console.WriteLine(len1); Console.WriteLine(arr1.LongLength); } }Output15 525
Read MoreCompare two strings lexicographically in C#
To compare strings in C#, use the compare() method. It compares two strings and returns the following integer values −If str1 is less than str2, it returns -1. If str1 is equal to str2, it returns 0. If str1 is greater than str2, it returns 1.Set the two strings in the String.compare() method and compare them −string.Compare(string1, string2);ExampleYou can try to run the following code to compare two strings in C#.using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { string ...
Read MoreDoes declaring an array create an array in C#?
Declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to the array.The following is a declaration and it will not create an array −int[] id;The following create an array of integers. The array is a reference type, so you need to use the new keyword to create an instance of the array −Int[] id = new int[5] {};Let us see an example −Exampleusing System; namespace ArrayApplication { public class MyArray { public static void Main(string[] args) { int [] ...
Read MoreHow to iterate two Lists or Arrays with one foreach statement in C#?
Set two arrays.var val = new [] { 20, 40, 60}; var str = new [] { "ele1", "ele2", "ele3"};Use the zip() method to process the two arrays in parallel.var res = val.Zip(str, (n, w) => new { Number = n, Word = w });The above fetches both the arrays with int and string elements respectively.Now, use foreach to iterate the two arrays −Exampleusing System; using System.Collections.Generic; using System.Linq; public class Demo { public static void Main() { var val = new [] { 20, 40, 60}; var str = new [] ...
Read MoreWhat is the use of 'new' keyword in C#?
Use the new keyword to create an instance of the array −int [] a = new int[5];The new operator is used to create an object or instantiate an object. Here in the example, an object is created for the class using the new −Exampleusing System; namespace CalculatorApplication { class NumberManipulator { public void swap(int x, int y) { int temp; temp = x; /* save the value of x */ x = y; /* put y into x */ ...
Read MoreBootstrap Horizontal Form
To create a horizontal form in Bootstrap, follow the below steps − Add a class of .form-horizontal to the parent element. Wrap labels and controls in a with class .form-group. Add a class of .control-label to the labels.You can try to run the following code to create a horizontal form in Bootstrap −Example Bootstrap Example First Name Last Name Remember me Sign in
Read More