Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 37 of 81

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

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 595 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 h1 = new HashSet < int > (arr1); // HashSet Two var h2 = new HashSet < int > (arr2); // HashSet Three var h3 = new HashSet < int > (arr3);Let us see the complete code to find common elements.Exampleusing System; using System.Collections.Generic; using System.Linq; public class Program ...

Read More

How do you make code reusable in C#?

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 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 the deriving classes would follow.For example, Shape Interface −public interface IShape {    void display(); }Above we have declared an Interface Shape. You can notice that it begins with a capital “I”. It is a common convention that interfaces names begin with “I”.We have not added an access specifier above ...

Read More

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

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 1K+ 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

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 514 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     | +-------------+----------+ | 1           | Rahul    | | 2           | Yashpal  | | 3           | Gaurav   | | 4           | Virender | +-------------+----------+ 4 rows in ...

Read More

Sorting a HashMap according to keys in C#

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 6K+ 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() method respectively.// get keys var val = d.Keys.ToList(); // sort val.Sort();The following is the complete example to sort a HashMap according to keys −Exampleusing System; using System.Collections.Generic; using System.Linq; class Program {    static void Main() {       Dictionary d = new Dictionary()     ...

Read More

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

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 6K+ 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 a list.A list is a group of items −List myList = new List() {    "Maths",    "English", "   Science" };Dictionary is a set of key-value pairs.Dictionary d = new Dictionary(); d.Add("squash", 1); d.Add("football", 2); d.Add("rugby", 3);Looping is easier and faster in a list and access element using index ...

Read More

Retrieve data value as a pointer in C#

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 950 Views

A pointer is a variable whose value is the address of another variable. Retrieve the data stored at the located referenced by the pointer variable, using the ToString() method.ExampleHere in an example −using System; namespace UnsafeCodeApplication {    class Program {       public static void Main() {          unsafe {             int var = 100;             int* p = &var;             Console.WriteLine("Data is: {0} " , var);             Console.WriteLine("Data is: {0} " , p->ToString());             Console.WriteLine("Address is: {0} " , (int)p);          }          Console.ReadKey();       }    } }OutputAbove will require you to set unsafe comman line option. After seeting it, the following output would be visible.Data is: 100 Data is: 100 Address is: 77678547

Read More

Inbuilt Data Structures in C#

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 604 Views

C# has a lot of inbuilt Data Structures. Here are two of them −ListGeneric List is a generic collection and the ArrayList is a non-generic collection. The size can be dynamicallyincreased using List, unlike Arrays.Let us see an example.We have set the List first −List myList = new List()ArrayListIt represents ordered collection of an object that can be indexed individually.Set an ArrayList as −ArrayList arr = new ArrayList(); arr.Add(67); arr.Add(34); arr.Add(99); arr.Add(45);

Read More

While linking two strings, if I will add a NULL value then what would be the output of a CONCAT() function?

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 147 Views

MySQL CONCAT() function will return a NULL if you will add a NULL value while linking two strings. Following example will demonstrate it −Examplemysql> Select CONCAT('Tutorials',NULL,'Point'); +----------------------------------+ | CONCAT('Tutorials',NULL,'Point') | +----------------------------------+ | NULL                             | +----------------------------------+ 1 row in set (0.06 sec) mysql> Select CONCAT('TutorialsPoint','.com',NULL); +--------------------------------------+ | CONCAT('TutorialsPoint','.com',NULL) | +--------------------------------------+ | NULL                                 | +--------------------------------------+ 1 row in set (0.00 sec)

Read More

Why is it good to write the numbers in MySQL INTERVAL() function in ascending order?

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 143 Views

Actually, INTERVAL() function uses the binary search for searching the bigger number than the number at first argument. So, that is why if we want INTERVAL() function to work efficiently the list of numbers would be in ascending order. Following is a good way to use INTERVAL() function −mysql> Select INTERVAL(50,20,32,38,40,50,55);

Read More
Showing 361–370 of 810 articles
« Prev 1 35 36 37 38 39 81 Next »
Advertisements