Arjun Thakur has Published 1025 Articles

How to find the Average Values of all the Array Elements in C#?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 09:55:47

225 Views

To find the average values, firstly set an arrayLint[] myArr = new int[10] {    45,    23,    55,    15,    8,    4,    2,    5,    9,    14 };Now find the sum and divide it by the length of the array to get the ... Read More

C# program to check if all the values in a list that are greater than a given value

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 09:47:12

2K+ Views

Let’s say you need to find the elements in the following list to be greater than 80.int[] arr = new int[] {55, 100, 87, 45};For that, loop until the array length. Here, res = 80 i.e. the given element.for (int i = 0; i < arr.Length; i++) {    if(arr[i] ... Read More

How to compile and execute C# programs on Linux?

Arjun Thakur

Arjun Thakur

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

1K+ Views

To compile and execute C# programs on Linux, firstly you need to IDE. On Linux, one of the best IDEs is Monodevelop.It 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. It has ... Read More

CopyOnWriteArrayList version in C#

Arjun Thakur

Arjun Thakur

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

248 Views

Java has CopyOnWriteArrayList, but C# does not have it. For that, the SynchronizedCollection Class in C#, should be preferred.The SyncronizedCollection has a thread-safe collection containing objects of a type. Here is the syntax.public class SynchronizedCollection : IList, ICollection, IEnumerable, IEnumerable, IList, ICollectionAbove, T is the type of object.The following are ... Read More

C# program to determine if any two integers in array sum to given integer

Arjun Thakur

Arjun Thakur

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

1K+ Views

The following is our array −int[] arr = new int[] {    7,    4,    6,    2 };Let’s say the given intger that should be equal to sum of two other integers is −int res = 8;To get the sum and find the equality.for (int i = 0; ... Read More

How to print a BinaryTriangle using C#?

Arjun Thakur

Arjun Thakur

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

540 Views

Binary triangle is formed with 0s and 1s. To create one, you need to work around a nestes for loop and display 0s and 1s till the row entered.for (int i = 1; i

How to check if an item exists in a C# list collection?

Arjun Thakur

Arjun Thakur

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

14K+ Views

Set a list −List < string > list1 = new List < string > () {    "Lawrence",    "Adams",    "Pitt",    "Tom" };Now use the Contains method to check if an item exits in a list or not.if (list1.Contains("Adams") == true) {    Console.WriteLine("Item exists!"); }The following is ... Read More

How to perform Multiplication of Exponents of same base using C#?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 08:21:12

225 Views

Firstly, set the base.double n = 2;Now set the two exponents for division.double e1 = 5; double e2 = 4;Let us see the complete code to get the result of multiplication of exponents of the same base.Example Live Demousing System; class Demo {    static void Main() {   ... Read More

How can we use a MySQL subquery with INSERT statement?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 08:09:02

900 Views

It can be understood with the help of an example in which we would copy the values of a table into other table. We are using the data from table ‘cars’ and copy its data to table ‘copy_cars’ −mysql> CREATE TABLE copy_cars LIKE cars; Query OK, 0 rows affected (0.86 ... Read More

Difference between TrimStart() and TrimEnd() in C#

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 07:53:25

922 Views

TrimStart() method removes all leading occurrences of a set of characters, whereas TrimEnd()removes all trailing occurrences of a set of characters.TrimStart()The TrimStart() method removes all leading occurrences of a set of characters specified in an array.Let us see an example to remove all leading zeros −Example Live Demousing System; class Program ... Read More

Advertisements