Karthikeya Boyini has Published 2383 Articles

How to find the Sum of two Binary Numbers using C#?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To find the sum of two binary numbers, firstly set them.val1 = 11110; val2 = 11100;Now call the displaySum() method, which created to display the sumL.sum = displaySum(val1, val2);We have set a new array in the method to display each bit of the binary number.long[] sum = new long[30];Now let ... Read More

How to check if a string is a valid keyword in C#?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

To check if a string is a valid keyword, use the IsValidIdentifier method.The IsValidIdentifier method checks whether the entered value is an identifier or not. If it’s not an identifier, then it’s a keyword in C#.Let us see an example, wherein we have set the CodeDomProvider and worked with the ... Read More

How to find the Rank of a given Array in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 10:03:27

184 Views

To find the rank of an array, use the Rank property.Firstly, declare and initialize an array.int[, ] myArr = new int[3, 3];Now, get the rank.myArr.RankLet us see the complete code −Example Live Demousing System; class Demo {    static void Main() {       int[, ] myArr = new int[3, ... Read More

C# program to find the most frequent element

karthikeya Boyini

karthikeya Boyini

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

781 Views

Let’s say our string is −String s = "HeathLedger!";Now create a new array.int []cal = new int[maxCHARS];Create a new method and pass both the string and the new array in it. Find the maximum occurrence of a character.static void calculate(String s, int[] cal) {    for (int i = 0; ... Read More

C# Program to replace a special character from a String

karthikeya Boyini

karthikeya Boyini

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

5K+ Views

Let’s say our string is −string str = "abcd$ef$gh";To replace the special character, use the Replace() method.string res = str.Replace('$', 'k');The following is the complete code to replace character from a string −Example Live Demousing System; public class Program {    public static void Main() {       string str ... Read More

How to find the first 10 characters of a string in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 09:56:07

11K+ Views

To get the first 10 characters, use the substring() method.Let’s say the following is our string −string str = "Cricket is a religion in India!";Now to get the first 10 characters, set the value 10 in the substring() method as shown below −string res = str.Substring(0, 10);Let us see the ... Read More

Find the Sum of two Binary Numbers without using a method in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 09:52:29

168 Views

First, declare and initialize two variables with the binary numbers.val1 = 11010; val2 = 10100; Console.WriteLine("Binary one: " + val1); Console.WriteLine("Binary two: " + val2);To get the sum, loop until both the value are 0.while (val1 != 0 || val2 != 0) {    sum[i++] = (val1 % 10 ... Read More

C# program to clone or copy a list

karthikeya Boyini

karthikeya Boyini

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

234 Views

To copy or clone a C# list, firstly set a list.List < string > myList = new List < string > (); myList.Add("One"); myList.Add("Two");Now declare a string array and use the CopyTo() method to copy.string[] arr = new string[10]; myList.CopyTo(arr);Let us see the complete code to copy a list into ... Read More

C# program to remove duplicate elements from a List

karthikeya Boyini

karthikeya Boyini

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

471 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

266 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

Advertisements