Chandu yadav has Published 1163 Articles

How to use the Clear method of array class in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 12:36:43

238 Views

The Array.Clear class in C# clears i.e.zeros out all elements.In the below example, we have first considered an array with 3 elements.int[] arr = new int[] { 11, 40, 20};Now we have used the Array.clear method to zero out all the arrays.Array.Clear(arr, 0, arr.Length);Let us see an example of Array.clear ... Read More

What are Base and Derived Classes in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 12:29:37

184 Views

A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.For example, Vehicle Base class with the following Derived Classes.Truck Bus MotobikeThe derived class inherits the base class member variables and member methods.In the ... Read More

What are accessors of properties in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 12:18:13

642 Views

Properties are an extension of fields and are accessed using the same syntax. They use accessors through which the values of the private fields can be read, written or manipulated.The accessor of a property contains the executable statements that helps in getting (reading or computing) or setting (writing) the property.Let ... Read More

How to create a thread in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 12:11:59

546 Views

Threads are lightweight processes. A thread is defined as the execution path of a program. Threads are created by extending the Thread class. The extended Thread class then calls the Start() method to begin the child thread execution.Example of Thread: One common example of use of thread is implementation of ... Read More

C# program to check whether a list is empty or not

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 11:48:02

8K+ Views

Use lists in C# to store elements and fetch it. Let us see an example.Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(string[] args) {       var subjects = new List();       subjects.Add("Maths");       subjects.Add("Java");       subjects.Add("English"); ... Read More

What is the scope of a protected internal member variable of a class in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 11:38:17

262 Views

The protected internal access specifier allows a class to hide its member variables and member functions from other class objects and functions, except a child class within the same application.In the below example, the derived class object can access the protected internal variable.Example Live Demousing System; class One {    protected ... Read More

What is the purpose of ‘as’ operator in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 11:32:35

113 Views

The "as" operator perform conversions between compatible types. It is like a cast operation and it performs only reference conversions, nullable conversions, and boxing conversions. The as operator can't perform other conversions, such as user-defined conversions, which should instead be performed by using cast expressions.The following is an example showing ... Read More

What is the scope of a private member variable of a class in C#?

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 11:29:11

306 Views

Only functions of the same class can access its private members. Private access specifier allows a class to hide its member variables and member functions from other functions and objects.Example Live Demousing System; namespace RectangleApplication {    class Rectangle {       //member variables       private double length; ... Read More

Comparing enum members in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 11:11:59

1K+ Views

To compare enum members, use the Enum.CompareTo() method.Firstly, set the values for students.enum StudentRank { Tom = 3, Henry = 2, Amit = 1 };Now use the compareTo() method to compare one enum value with another.Console.WriteLine( "{0}{1}", student1.CompareTo(student2) > 0 ? "Yes" : "No", Environment.NewLine );The following is the code ... Read More

Dynamic Binding in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 11:02:14

868 Views

In Dynamic binding, the compiler will not do type checking at compile time. At run time, the checking is done.Use it to avoid the restriction of anonymous types to one method. This is only because the type name is visible only to the compiler; therefore, you cannot declare it as ... Read More

Advertisements