Samual Sam has Published 2492 Articles

How do you find the number of dimensions of an array in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:48:43

608 Views

To find the number of dimensions of an array, use the Rank property.arr.RankHere, arr is our array −int[, ] arr = new int[3, 4];If you also want to get the rows and columns it has, then use the GetLength property −arr.GetLength(0); arr.GetLength(1);The following is the complete code −Example Live Demousing System; ... Read More

What is the Count property of ArrayList class in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:46:48

216 Views

The Count property in the ArrayList class counts the number of elements in the ArrayList.Firstly, add elements to the ArrayList −ArrayList arrList = new ArrayList(); arrList.Add(98); arrList.Add(55); arrList.Add(65); arrList.Add(34);Then get the count of the array list −arrList.CountThe following is the code to implement Count property in C# −Example Live Demousing ... Read More

How to declare variables in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:44:25

239 Views

Each variable in C# has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.To declare variables − ;Let us see an example to ... Read More

What are member functions of a class in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:43:18

2K+ Views

A member function of a class is a function that has its definition or its prototype within the class definition similar to any other variable. It operates on an object of the class of which it is a member, and has access to all the members of a class for ... Read More

How to define a rectangular array in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:40:44

719 Views

Multi-dimensional arrays are also called rectangular array. You can define a 3-dimensional array of integer as −int [ , , ] a;Let us see how to define a two-dimensional array −Int[, ] a = new[3, 3]The following is an example showing how to work with a multi-dimensional i.e. rectangular array ... Read More

What is Type casting in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:38:06

246 Views

Type casting is converting one type of data to another type. The two forms are −Implicit type conversion − These conversions are performed by C# in a type-safe manner. For example, are conversions from smaller to larger integral types and conversions from derived classes to base classes.Explicit type conversion− These ... Read More

Iterators in C#

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:30:53

285 Views

Iterator performs a custom iteration over a collection. It uses the yield return statement and returns each element one at a time. The iterator remembers the current location and in the next iteration the next element is returned.The following is an example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; ... Read More

How to declare an event in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:29:25

274 Views

Events are user actions such as key press, clicks, mouse movements, etc., or some occurrence such as system-generated notifications.The events are declared and raised in a class and associated with the event handlers using delegates within the same class or some other class. The class containing the event is used ... Read More

How to declare and initialize a list in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:28:04

11K+ Views

To declare and initialize a list in C#, firstly declare the list −List myList = new List()Now add elements −List myList = new List() {    "one",    "two",    "three", };Through this, we added six elements above.The following is the complete code to declare and initialize a list in ... Read More

How to declare and instantiate Delegates in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:26:30

251 Views

C# delegates are similar to pointers to functions, in C or C++. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Syntax for declaring Delegates −delegate Let us now see how to instantiate delegates in C#.Once a ... Read More

Advertisements