karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 63 of 143

How to call a method of a class in C#

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

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 More

Random Numbers in C#

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

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 More

Create a tabbed menu with Bootstrap

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

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 More

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

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

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

Read More

Bootstrap Accordion

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

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 More

What are dynamic arrays in C#?

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

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 More

C# program to count the occurrences of each character

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

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 More

C# Program to find the largest element from an array

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

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 More

C# program to count total set bits in a number

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

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 More

What are the differences between ref and out parameters in C#?

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

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
Showing 621–630 of 1,421 articles
« Prev 1 61 62 63 64 65 143 Next »
Advertisements