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 63 of 143
How to call a method of a class in C#
To call a method, use the name of the method after the object name, for example, −obj1. Display();Let’s say the class name is ApplicationOne, so to call the method −ApplicationOne one = new ApplicationOne(); //calling the displayMax method ret = one.displayMax(a, b);The following is the example showing how to call a method in C# −Exampleusing System; namespace Demp { class ApplicationOne { public int displayMax(int num1, int num2) { /* local variable declaration */ int result; if (num1 > num2) ...
Read MoreRandom Numbers in C#
To generate random numbers in C#, use the Next(minValue, MaxValue) method. The parameters are used to set the minimum and maximum values.Next(100,200);We have set the above method under Random() object.Random rd = new Random(); int rand_num = rd.Next(100,200);The following is an example −Exampleusing System; class Program { static void Main() { Random rd = new Random(); int rand_num = rd.Next(100,200); Console.WriteLine(rand_num); } }Output182
Read MoreCreate a tabbed menu with Bootstrap
To create a tabbed menu with Bootstrap, you can try to run the following codeExample Bootstrap Example Database The following are the database technologies: DB2 MySQL SQL CouchDB
Read MoreHow to generate the first 100 even Numbers using C#?
To generate first 100 even numbers, set a for loop from 1 to 100.for(val = 1; val
Read MoreBootstrap Accordion
To create an Accordion in Bootstrap, you can try to run the following codeExample Bootstrap Example My Website Tutorials We provide tutorials on C, C++, Java, PHP, Networking, SEO, C++, C, etc. Quiz We provide quizzes on C, C++, Java, PHP, Ruby, DBMS, Networking, SEO, etc.
Read MoreWhat are dynamic arrays in C#?
Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.To create arrays dynamically in C#, use the ArrayList collection. It represents an ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.The following is an example showing how to create arrays dynamically in C# −Exampleusing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); ...
Read MoreC# program to count the occurrences of each character
Firstly, set the string −string str = "Website"; Console.WriteLine("String: "+str);Check for every character in the string and increment a variable that would count the number of occurrences of that character −for (int j = 0; j < str.Length; j++) { if (str[0] == str[j]) { cal++; } }ExampleYou can try to run the following code to count the occurrences of each character.using System; public class Demo { public static void Main() { string str = "Website"; Console.WriteLine("String: "+str); while (str.Length > 0) { ...
Read MoreC# Program to find the largest element from an array
Declare an array −int[] arr = { 20, 50, -35, 25, 60 };Now to get the largest element from an array, use the Max() method −arr.Max());Here is the complete code −Exampleusing System; using System.Linq; class Demo { static void Main() { int[] arr = { 20, 50, -35, 25, 60 }; Console.WriteLine(arr.Max()); } }Output60
Read MoreC# program to count total set bits in a number
The number for our example is 11 i.e. binary −1101The total set bits are 3 in 1101; to find it, use a loop till it’s not equal to 0. Here, our num is 11 i.e. decimal −while (num>0) { cal += num & 1; num >>= 1; }ExampleTo count total set bits in a number, use the following code.using System; public class Demo { public static void Main() { int cal = 0; // Binary is 1011 int num = 11; while (num>0) { cal += num & 1; num >>= 1; } // 1 bits in 1101 are 3 Console.WriteLine("Total bits: "+cal); } }OutputTotal bits: 3
Read MoreWhat are the differences between ref and out parameters in C#?
Ref ParameterA reference parameter is a reference to a memory location of a variable. When you pass parameters by reference, unlike value parameters, a new storage location is not created for these parameters.You can declare the reference parameters using the ref keyword. The following is an example −Exampleusing System; namespace CalculatorApplication { class NumberManipulator { public void swap(ref int x, ref int y) { int temp; temp = x; /* save the value of x */ x = y; /* put y ...
Read More