Karthikeya Boyini has Published 2193 Articles

C# program to remove duplicate elements from a List

karthikeya Boyini

karthikeya Boyini

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

649 Views

Declare a list and add elements.List list = new List(); list.Add(50); list.Add(90); list.Add(50); list.Add(100);Now, use Distinct() method to get the unique elements only.List myList = list.Distinct().ToList();The following is the complete code to remove duplicate elements from a List −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo { ... Read More

Synchronization and Pooling of processes in C#

karthikeya Boyini

karthikeya Boyini

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

469 Views

Using Synchronization, you can synchronize access to resources in multithreaded applications.A 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 of ... Read More

Thread Safe Concurrent Collection in C#

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

The .NET Framework 4 brought the System.Collections.Concurrent namespace. This has several collection classes that are thread-safe and scalable. These collections are called concurrent collections because they can be accessed by multiple threads at a time.The following are the concurrent collection in C# −Sr.NoType & Description1BlockingCollectionBounding and blocking functionality for any ... Read More

How to compile and execute C# programs on Mac OS?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To compile and execute C# programs on Mac, firstly you need to IDE. On MacOS, one of the best IDEs is Monodevelop.Monodevelop is an open source IDE that allows you to run C# on multiple platforms i.e. Windows, Linux, and MacOS. MonoDevelop is also known as Xamarin Studio.Monodevelop has a ... Read More

C# program to find all duplicate elements in an integer array

karthikeya Boyini

karthikeya Boyini

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

9K+ Views

Firstly, set the array with duplicate elements.int[] arr = {    24,    10,    56,    32,    10,    43,    88,    32 };Now declare a Dictionary and loop through the array to get the repeated elements.var d = new Dictionary < int, int > (); foreach(var ... Read More

C# Program to find number of occurrence of a character in a String

karthikeya Boyini

karthikeya Boyini

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

966 Views

Let’s say our string is −String s = "mynameistomhanks";Now create a new array and pass it a new method with the string declared above. This calculates the occurrence of characters in a string.static void calculate(String s, int[] cal) {    for (int i = 0; i < s.Length; i++)   ... Read More

Understanding Logistic Regression in C#

karthikeya Boyini

karthikeya Boyini

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

409 Views

The Logistic regression is a linear model used for binomial regression. It is used in medical science and to predict a customer’s tendency to purchase a product. It makes use of predictor variables for this purpose.Logistic Regression allows easier analysis of results in the form of odds ratios and statistical ... Read More

Formatted string literals in C#

karthikeya Boyini

karthikeya Boyini

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

577 Views

To format string literals in C#, use the String.Format method.In the following example, 0 is the index of the object whose string value gets inserted at that particular position −using System; namespace Demo {    class Test {       static void Main(string[] args) {         ... Read More

C# program to print all distinct elements of a given integer array in C#

karthikeya Boyini

karthikeya Boyini

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

576 Views

We have set an array and a dictionary to get the distinct elements.int[] arr = {    88,    23,    56,    96,    43 }; var d = new Dictionary < int, int > ();Dictionary collection allows us to get the key and value of a list.The following ... Read More

How to print a blank line in C#?

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

To display a line in C#, use the Console.WriteLine().Under that set a blank line −Console.WriteLine(" ");The following is the code that displays a blank line −Example Live Demousing System; namespace Program {    public class Demo {       public static void Main(String[] args) {         ... Read More

Advertisements