Samual Sam has Published 2492 Articles

C# and Multiple Inheritance

Samual Sam

Samual Sam

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

5K+ Views

Multiple Inheritance isn’t supported in C#. To implement multiple inheritances, use Interfaces.Here is our interface PaintCost in class Shape −public interface PaintCost {    int getCost(int area); }The shape is our base class whereas Rectangle is the derived class −class Rectangle : Shape, PaintCost {    public int getArea() { ... Read More

C# Example for Hierarchical Inheritance

Samual Sam

Samual Sam

Updated on 19-Jun-2020 08:32:41

3K+ Views

More than one class is inherited from the base class in Hierarchical Inheritance.In the example, our base class is Father −class Father {    public void display() {       Console.WriteLine("Display...");    } }It has Son and Daughter as the derived class. Let us how to add a derived ... Read More

C# program to check if string is panagram or not

Samual Sam

Samual Sam

Updated on 19-Jun-2020 08:28:49

1K+ Views

A pangram has all the 26 letters of an alphabet.Below, we have entered a string, and will check whether it is a pangram or not −string str = "The quick brown fox jumps over the lazy dog";Now, check using the ToLower(), isLetter() and Count() functions that the string has all ... Read More

Boxing and Unboxing in C#

Samual Sam

Samual Sam

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

1K+ Views

BoxingBoxing is the implicit conversion of a value type to a reference type.UnboxingUnboxing is the explicit conversion of the reference type created by boxing, back to a value type.ExampleLet us see an example code snippet −// int int myVal = 12; // Boxing object myBoxed = myVal; // Unboxing int ... Read More

Background Worker Class in C#

Samual Sam

Samual Sam

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

1K+ Views

As the name suggests the Background Worker Class allows you to set a thread continuously running in the background and communicating with the main thread whenever required.BackgroundWorker makes the implementation of threads in Windows Forms. Intensive tasks need to be done on another thread so the UI does not freeze. ... Read More

BigInteger Class in C#

Samual Sam

Samual Sam

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

394 Views

Use the BigInteger to handle big numbers in C#. The assembly to add for BigInteger is System. Numerics.In c# Big integer is found in System.Numerics.BigInteger.SyntaxThe syntax of BigInteger −[SerializableAttribute] public struct BigInteger : IFormattable, IComparable, IComparable, IEquatableLet us see an example code snippet −BigInteger num = BigInteger.Multiply(Int64.MaxValue, Int64.MaxValue);You can create ... Read More

Binary to decimal using C#

Samual Sam

Samual Sam

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

157 Views

To convert binary to decimal, here I have used a while loop and found the remainder of the Binary number, which is the input. After that, the remainder is multiplied by the base value and added.This is what I did to get the decimal value −while (val > 0) { ... Read More

C# program to check if binary representation is palindrome

Samual Sam

Samual Sam

Updated on 19-Jun-2020 08:15:05

203 Views

To check for palindrome, let us say our number is 5, whose binary is −101The palindrome of 101 is 101 and to check you need to reverse the bits using the following function. Here, bitwise left and bitwise right shift operators are used −public static long funcReverse(long num) {   ... Read More

Are arrays zero indexed in C#?

Samual Sam

Samual Sam

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

765 Views

Yes, arrays zero indexed in C#. Let us see how −If the array is empty, it has zero elements and has length 0.If the array has one element in 0 indexes, then it has length 1.If the array has two elements in 0 and 1 indexes, then it has length ... Read More

abstract keyword in C#

Samual Sam

Samual Sam

Updated on 19-Jun-2020 08:12:01

551 Views

The abstract keyword in C# is used for abstract classes. An abstract class in C# includes abstract and nonabstract methods. You cannot instantiate an abstract class.Example of an abstract class Vehicle and abstract method display() −public abstract class Vehicle {    public abstract void display(); }The abstract class has derived ... Read More

Advertisements