How to initialize multi-dimensional arrays in C#?

karthikeya Boyini
Published on 18-Sep-2018 11:13:15
The simplest form of the multidimensional array is the 2-dimensional array. A 2-dimensional array is a list of one-dimensional arrays.Multidimensional arrays may be initialized by specifying bracketed values for each row.int [, ] a = new int [3, 4] {    {0, 1, 2, 3} , /* initializers for row ... Read More

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

Chandu yadav
Published on 18-Sep-2018 11:08:23
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

What is the Queue class in C#?

Samual Sam
Published on 18-Sep-2018 11:08:16
To represent a first-in first-out collection of objects in C#, use the Queue class. When you add an item in the list, it is called enqueue, and when you remove an item, it is called deque.Some of the methods of the Queue class include.Sr.NoMethod & Description1public virtual void Clear();Removes all ... Read More

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

Chandu yadav
Published on 17-Sep-2018 17:51:03
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

C# program to sort an array in descending order

Samual Sam
Published on 17-Sep-2018 17:50:52
Initialize the array.int[] myArr = new int[5] {98, 76, 99, 32, 77};Compare the first element in the array with the next element to find the largest element, then the second largest, etc.if(myArr[i] < myArr[j]) {    temp = myArr[i];    myArr[i] = myArr[j];    myArr[j] = temp; }Above, i and ... Read More

C# program to determine if a string has all unique characters

George John
Published on 17-Sep-2018 17:47:00
Use the substring() method in C# to check each and every substring for unique characters. Loop it until the length of the string.If any one the substring matches another, then it would mean that the string do not have unique characters.You can try to run the following code to determine ... Read More

Difference between C# and .Net

karthikeya Boyini
Published on 17-Sep-2018 17:47:02
C# is a programming language and .NET is a framework. .NET has Common Language Runtime (CLR), which is a virtual component of .NET framework. .NET not only has C#, but through it, you can work with VB, F#, etc. C# is a part of .NET and has the following ... Read More

C# program to find maximum and minimum element in an array

Ankith Reddy
Published on 17-Sep-2018 17:40:59
Set the minimum and maximum element to the first element so that you can compare all the elements.For maximum.if(arr[i]>max) {    max = arr[i]; }For minimum.if(arr[i]<min) {    min = arr[i]; }You can try to run the following code to find maximum and minimum elements’ position.Example Live Demousing System; public class ... Read More

Explain C# Grouping Constructs in regular expression

Samual Sam
Published on 17-Sep-2018 17:39:38
There are various categories of characters, operators, and constructs that lets you to define regular expressions. One of them is Grouping Constructs. Grouping constructs describe sub-expressions of a regular expression and capture substrings of an input string. The following table lists the grouping constructs. Grouping construct Description Pattern ... Read More

What is the Item property of Hashtable class in C#?

Arjun Thakur
Published on 17-Sep-2018 17:36:34
Gets or sets the value associated with the specified key. You can also use the Item property to add new elements.If a key does not exist, then you can include it like −myCollection["myNonexistentKey"] = myValueThe following is the code showing how to work with Item property of Hashtable class in ... Read More
Advertisements