George John has Published 1167 Articles

Deadlock and Starvation in C#

George John

George John

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

1K+ Views

Deadlock occurs when a resource is locked by a thread and is required by another thread at the same time. This problem occur frequenty in a multiprocessing system.It can occur when two or more threads wait for a resource that belon to another thread. Here is an example −Thread OneThread ... Read More

Singly LinkedList Traversal using C#

George John

George John

Updated on 22-Jun-2020 10:16:46

143 Views

Declare a LinkedList using the LinkedList collection in X# −var a = new LinkedList < string > ();Now add elements to the LinkedList −a.AddLast("Tim"); a.AddLast("Tom");Let us see how to perform traversal in a LinkedList −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(string[] args) { ... Read More

Find power of a number using recursion in C#

George John

George John

Updated on 22-Jun-2020 10:09:37

169 Views

To find the power of a number, firstly set the number and the power −int n = 15; int p = 2;Now create a method and pass these values −static long power(int n, int p) {    if (p != 0) {       return (n * power(n, p ... Read More

How to find whether the Number is Divisible by 2 using C#?

George John

George John

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

200 Views

To find whether a number is divisibe by 2 is not, check what happens when the number is divisible by 2.If the remainder is 0, then the number is divisible by 2, else it is false −if (num % 2 == 0) {    Console.WriteLine("Divisible by 2 "); } else ... Read More

C# program to check the validity of a Password

George John

George John

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

6K+ Views

For validity of a password, you need to recall the concept when your create a password to signup to a website.While creating a password, you may have seen the validation requirements on a website like a password should be strong and have −Min 8 char and max 14 charOne upper ... Read More

C# program to remove all duplicates words from a given sentence

George John

George John

Updated on 22-Jun-2020 09:44:04

1K+ Views

Set a string with duplicate words.string str = "One Two Three One";Above, you can see the word “One” comes twice.To remove dulicate words, you can try to run the following code in C# −Example Live Demousing System; using System.Linq; public class Program {    public static void Main() {     ... Read More

What is the equivalent of a VB module in C#?

George John

George John

Updated on 22-Jun-2020 09:42:31

733 Views

In VB, a module is used to store loose code accessible from elsewhere in the application without having to first initialize something.The state of the variable can be easily set or changed and that continues to carry on that value throughout.For the same work in C#< use a static class.Let ... Read More

C# program to convert time from 12 hour to 24 hour format

George John

George John

Updated on 22-Jun-2020 09:36:23

10K+ Views

Firstly, set the 12 hr format date.DateTime d = DateTime.Parse("05:00 PM");Now let us convert it into 24-hr format.d.ToString("HH:mm"));The following is the code to covert time from 12 hour to 24 hour format −Example Live Demousing System; namespace Demo {    public class Program {       public static void Main(string[] ... Read More

What is an object pool in C#?

George John

George John

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

1K+ Views

Object pool is a software construct designed to optimize the usage of limited resources. It has objects that are ready to be used.The pooled objects can be reused. The object pooling has two forms −On activation of the object, it is pulled from pool.On deactivation, the object is added to ... Read More

Style every element that is the only child of its parent with CSS

George John

George John

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

100 Views

Use the CSS :only-child selector to style every element that is the only child of its parent.ExampleYou can try to run the following code to implement the :only-child selectorLive Demo                    p:only-child {             ... Read More

Advertisements