Chandu yadav has Published 1163 Articles

What will happen to MySQL current transaction, if in the middle of that transaction, the DDL statement is executed?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 11:30:35

212 Views

The current MySQL transaction will be committed and ended when any of the DDL statement such as CREATE or DROP databases, Create, ALTER or DROP tables or stored routines is executed in the middle of the current transaction. All the database changes made in the current transaction will be made ... Read More

How to clone a generic list in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 11:02:47

354 Views

A list is a Generic collection to hold elements of same datatypes.To clone a list, you can use the CopyTo method.Declare a list and add elements −List < string > myList = new List < string > (); myList.Add("Programming"); myList.Add("Web Dev"); myList.Add("Database");Now create a new array and clone the list ... Read More

C# program to merge two Dictionaries

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 10:52:52

1K+ Views

Set the two dictionaries −Dictionary < string, int > dict1 = new Dictionary < string, int > (); dict1.Add("laptop", 1); dict1.Add("desktop", 2); Dictionary < string, int > dict2 = new Dictionary < string, int > (); dict2.Add("desktop", 3); dict2.Add("tablet", 4); dict2.Add("mobile", 5);Now use HashSet and UnionWith() method to merge the ... Read More

Thread Synchronization in C#

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 10:15:44

467 Views

Synchronize access to resources in multithreaded applications using Synchronization.Mutex to Synchronize ThreadsA mutex can be used to synchronize threads across processes. Use it to prevent the simultaneous execution of a block of code by more than one thread at a time.C# lock statement is used to ensure that a block ... Read More

How to get the nth value of a Fibonacci series using recursion in C#?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 10:13:04

1K+ Views

Create a method to get the nth value with recursion.public int displayFibonacci(int n)Call the method −displayFibonacci(val)On calling, the displayFibonacci() meyhod gets called and calculate the nth value using recursion.public int displayFibonacci(int n) {    if (n == 0) {       return 0;    }    if (n == ... Read More

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

Chandu yadav

Chandu yadav

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

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

411 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

168 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

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

Advertisements