Chandu yadav has Published 1090 Articles

How to find the size of a list in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:59:59

3K+ Views

Declare and initialize a list.var products = new List (); products.Add("Accessories"); products.Add("Clothing"); products.Add("Footwear");To get the size, use the Capacity property.products.CapacityNow let us see the complete code to find the size of a list.Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(string[] args) {     ... Read More

How to find the sum of digits of a number using recursion in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:54:46

614 Views

To get the sum of digits using recursion, set a method in C# that calculates the sum.static int sum(int n) {    if (n != 0) {       return (n % 10 + sum(n / 10));    } else {       return 0;    }The above ... Read More

C# program to remove an item from Set

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:45:15

274 Views

Firstly, declare a HashSet and add elements −var names = new HashSet(); names.Add("Tim"); names.Add("John"); names.Add("Tom"); names.Add("Kevin");To remove an element, use RemoveWhere.names.RemoveWhere(x => x == "John");Let us see the complete example −Exampleusing System; using System.Collections.Generic; public class Program {    public static void Main() {       var names = ... Read More

What is the difference between public, static and void keywords in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:43:18

14K+ Views

All these keywords are part of the main method of any C# program.The Main method, which is the entry point for all C# programs states that what a class does when it executed.using System; class Demo {    static void Main(string[] args) {       Console.WriteLine("My first program in C#!");    } ... Read More

How to compile and execute C# programs on Windows?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:38:14

1K+ Views

The best IDE for C# on Windows is Microsoft Visual Studio. It is an IDE to develop websites, web apps, mobile apps, etc.The following are the features of Visual Studio IDE −Code Editor − Visual Studio has a code editor supporting syntax highlighting and code completion using IntelliSense.Breakpoints − Set ... Read More

C# program to find common elements in three arrays using sets

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:34:05

535 Views

Set three arraysint[] arr1 = {    99,    57,    63,    98 }; int[] arr2 = {    43,    99,    33,    57 }; int[] arr3 = {    99,    57,    42 };Now set the above elements using HashSet.// HashSet One var ... Read More

How do you make code reusable in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:27:05

2K+ Views

To make code reusable in C#, use Interfaces. Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members. It often helps in providing a standard structure that ... Read More

C# Program to perform Currency Conversion

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:19:32

4K+ Views

Let’s say you need to get the value of 10 dollars in INR.Firstly, set the variables: double usd, inr, val;Now set the dollars and convert it to INR.// how many dpllars usd = 10; // current value of US$ val = 69; inr = usd * val;Let us see the ... Read More

How to print a line on the console using C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:16:02

739 Views

To display a line, Console.Write() is used in C#.Console displays the result on the console. I have first set a string.string str = "Tom Hanks is an actor";Now displaying the above line.Console.WriteLine(str);The following is the complete code −Example Live Demousing System; namespace Program {    public class Demo {     ... Read More

How to find and display the Multiplication Table in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 09:00:08

951 Views

To display multiplication table, you need to set the numbers and format the output property. Let’s say you want to find the table of 4 from 1 to 10. For that, set a while loop first till 10.while (a

Advertisements