Karthikeya Boyini has Published 2383 Articles

C# Multiple Local Variable Declarations

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:54:19

611 Views

In C#, you can use the comma to declare more than one local variable in a statement. The following displays the same −int a = 20, b = 70, c = 40, d = 90;ExampleLet us see an example in which we are declaring multiple local variables. Below four variable ... Read More

Bubble Sort program in C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:36:06

15K+ Views

Bubble sort is a simple sorting algorithm. This sorting algorithm is a comparison-based algorithm in which each pair of adjacent elements is compared and the elements are swapped if they are not in order.Let’s say our int has 5 elements −int[] arr = { 78, 55, 45, 98, 13 };Now, ... Read More

C# program to check if a Substring is present in a Given String

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:30:11

460 Views

Use the contains() method in C# to check if a substring is in a given string.Let us say the string is −UnitedWithin the string, you need to find the substring “Uni”. For that, use the contains method and use it like the following code snippet −res = str1.Contains(str2);ExampleYou can try ... Read More

C# program to check if two matrices are identical

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:27:53

437 Views

To check whether the matrices are identical or not, you need to first check whether the matrixes can be compared or not, since for comparison at least the dimensions of the two matrices should be the same.if (row1 != row2 && col1 != col2) {    Console.Write("Matrices can't be compared:"); ... Read More

Async & await keyword in C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:26:51

855 Views

The async and await keyword is used in C# for asynchronous programming.An application with a GUI, check the content of the queue and if an unprocessed task is there, it takes it out and processes it first. The code executes synchronously and the unprocessed task is completed first. The application ... Read More

Background and foreground thread in C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:25:21

546 Views

A thread is defined as the execution path of a program. Each thread defines a unique flow of controlBackground ThreadsWhen the foreground threads will close, the background threads will be terminated.The property used for background thread is IsBackground that gets or sets a value indicating whether a thread is a ... Read More

Basic calculator program using C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:24:03

776 Views

To create a calculator program in C#, you need to use Web Forms. Under that create buttons from 1-9, addition, subtraction, multiplication, etc.Let us see the code for addition, subtraction, and multiplication. Firstly, we have declared two variables −static float x, y;Now, we will see how to set codes for ... Read More

Binary search in C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:20:38

10K+ Views

Binary search works on a sorted array. The value is compared with the middle element of the array. If equality is not found, then the half part is eliminated in which the value is not there. In the same way, the other half part is searched.Here is the mid element ... Read More

Bitwise right shift operators in C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:18:07

579 Views

Bitwise operator works on bits and performs bit by bit operation. In Bitwise right shift operator the value of the left operand is moved right by the number of bits specified by the right operand.In the below code, we have the value −60 i.e. 0011 1100On the right shift %minus;c ... Read More

Assertions in C#

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:14:00

2K+ Views

Assert statements are an effective way to catch program logic errors at runtime. It has two arguments −A boolean expression for a true condition, andWhat to display in case of false.Assertions are useful in large and complex programs to quickly flush out errors that generally arise when the code is ... Read More

Advertisements