Chandu yadav has Published 1163 Articles

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

Chandu yadav

Chandu yadav

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

390 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

1K+ 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

3K+ 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

597 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

725 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

How to read inputs as strings in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 08:55:10

7K+ Views

To read inputs as strings in C#, use the Console.ReadLine() method.str = Console.ReadLine();The above will read input as string. You don’t need to use the Convert method here since the input takes string by default.Now display the string entered by user −Example Live Demousing System; using System.Collections.Generic; class Demo { ... Read More

How MySQL evaluates if we use EXISTS operator with the subquery that returns NULL?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 08:43:34

357 Views

If a subquery, used with EXIST operator, returns NULL, the expression EXIST NULL returns TRUE and MySQL returns the result based on an outer query. It can be understood with the help of simple example using the following data from table ‘Customers’ −mysql> Select * from Customers; +-------------+----------+ | Customer_Id | Name ... Read More

Large Fibonacci Numbers in C#

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 08:33:12

366 Views

To display large Fibonacci numbers, try the following login and code.Here, we have set the value of n as the series. Set it to get the Fibonacci number. Below, we have set it to 100 to get the first 100 Fibonacci numbers.Since the first two numbers in a Fibonacci series ... Read More

Sorting a HashMap according to keys in C#

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 08:28:50

5K+ Views

HashMap is in Java, not C#. The equivalent of HashMap in C# is Dictionary that is used as a collection of key-value pair.Firstly, set the Dictionary −Dictionary d = new Dictionary(); d.Add("soccer", 1); d.Add("cricket", 2); d.Add("tennis", 3); d.Add("rugby", 4);Now get the keys and sort them using ToList() and Sort() ... Read More

What is the difference between list and dictionary in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 08:20:30

5K+ Views

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace. Dictionary is a generic type and returns an error if you try to find a key which is not there.List collection is a generic class and can store any data types to create ... Read More

Advertisements