Karthikeya Boyini has Published 2193 Articles

C# program to convert binary string to Integer

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 09:02:11

1K+ Views

Use the Convert.ToInt32 class to fulfill your purpose of converting a binary string to an integer.Let’s say our binary string is −string str = "1001";Now each char is parsed −try {    //Parse each char of the passed string    val = Int32.Parse(str1[i].ToString());    if (val == 1)     ... Read More

C# Program to Convert Character case

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 09:01:03

556 Views

Let’s say your string is −str = "AMIT";To convert the above uppercase string in lowercase, use the ToLower() method −Console.WriteLine("Converted to LowerCase : {0}", str.ToLower());ExampleThe following is the code in C# to convert character case.Live Demousing System; using System.Collections.Generic; using System.Text; namespace Demo {    class MyApplication {     ... Read More

C# Example for Single Inheritance

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 08:58:59

4K+ Views

The following is an example of Single Inheritance in C#. In the example, the base class is Father and declared like the following code snippet −class Father {    public void Display() {       Console.WriteLine("Display");    } }Our derived class is Son and is declared below −class Son ... Read More

C# Generics vs C++ Templates

karthikeya Boyini

karthikeya Boyini

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

606 Views

C# Generics and C++ Templates provide support for parameterized types. The following are the differences −FlexibilityC++ Templates are more flexible than C# GenericsExplicit specializationExplicit specialization is not supported by C#Type ParameterThe type parameter cannot be used as the base class for the generic type in C#C# does not allow type ... Read More

C# Multiple Local Variable Declarations

karthikeya Boyini

karthikeya Boyini

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

774 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

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

606 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

667 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

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

819 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

Advertisements