Arjun Thakur has Published 1109 Articles

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

Arjun Thakur

Arjun Thakur

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

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

Pattern matching in C# with Regex

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 08:35:54

314 Views

A regular expression is a pattern that could be matched against an input text. A pattern consists of one or more character literals, operators, or constructs.Let us see an example to display the words starting with the letter ‘M’ using Regex.Example Live Demousing System; using System.Text.RegularExpressions; namespace Demo {   ... 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

131 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

571 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

539 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

Infinity or Exception in C# when divide by 0?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 07:43:38

1K+ Views

Divide by zero is the System.DivideByZeroException, which is a class that handles errors generated from dividing a dividend with zero.Let us see an example.Example Live Demousing System; namespace ErrorHandlingApplication {    class DivNumbers {       int result;       DivNumbers() {          result = ... Read More

Difference between prefix and postfix operators in C#?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 07:35:26

6K+ Views

Prefix OperatorThe increment operator ++ if used as prefix on a variable, the value of variable gets incremented by 1. After that the value is returned unlike Postfix operator. It is called Prefix increment operator. In the same way the prefix decrement operator works but it decrements by 1.For example, an ... Read More

How can we retrieve the output having decimal values of a column in a specified format?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 07:29:37

462 Views

MySQL FORMAT() function, converts a number to a format like #, ###, ###.### which is rounded up to the number of decimal places specified and returns the result as a string, can be used to retrieve the output having decimal values of a column in a specified format. To understand ... Read More

Using the new keyword in C#

Arjun Thakur

Arjun Thakur

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

7K+ Views

Use the new keyword to create an instance of the array. The new operator is used to create an object or instantiate an object. Here in the example an object is created for the class using the new.The following is an example.Calculate c = new Calculate();You can also use the ... Read More

What is the difference between String.Copy() and String.CopyTo() methods in C#?

Arjun Thakur

Arjun Thakur

Updated on 22-Jun-2020 07:22:38

166 Views

String.CopyTo() method gets the string characters and places them into an array. A group of characters are copied from source string into a character array.The following is the Copy() method −Example Live Demousing System; class Demo {    static void Main(String[] args) {       string str = "This ... Read More

Advertisements