Karthikeya Boyini has Published 2193 Articles

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

karthikeya Boyini

karthikeya Boyini

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

152 Views

The IsReadOnly property of ArrayList class is useful to get a value indicating whether the ArrayList is read-only.Firstly, we have the following ArrayList.ArrayList arrList = new ArrayList();Then we have checked using the IsReadOnly Property.Console.WriteLine("myArrayList.IsReadOnly = " + arrList.IsReadOnly);The following is an example showing how to work with IsReadOnly property in ... Read More

How to Initialize and Compare Strings in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:45:50

241 Views

To initializes a string in C# is an easy task. Let’s say you want to set a name “Amit”, for that, initialize your string as.String str1 = "Hello, World!";To compare strings, use the the following C# method.public static int Compare(string str1, string str2)To compare, if −String.Compare(str1, str2) == 0If the ... Read More

How do you use ‘foreach’ loop for iterating over an array in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:41:04

476 Views

The for each loop similar to the for loop; however, the loop is executed for each element in an array or group. Therefore, the index does not exist in foreach loop.Let us see an example of Bubble Sort, wherein after sorting the elements, we will display the elements using the ... Read More

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

karthikeya Boyini

karthikeya Boyini

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

91 Views

A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index.Gets and sets the value associated with a specific key in the SortedList.You can also use the Item property to add new ... Read More

How to set the style of the bottom border with JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:13:22

351 Views

To set the style of the bottom border, use the JavaScript borderBottomStyle property. It allows you to add a bottom border.ExampleYou can try to run the following code to set the style of the bottom border −           Demo Text         ... Read More

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

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:10:37

250 Views

The "is" operator in C# checks whether the run-time type of an object is compatible with a given type or not.The following is the syntax.expr is typeHere, expr is the expressiontype is the name of the typeThe following is an example showing the usage of is operator in C#.Exampleusing System; ... Read More

Const vs Static vs Readonly in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:03:56

1K+ Views

ConstConstant fields are the fields that cannot be modified. At the time of declaration, you need to assign a value to it.const int a = 5;StaticIf the static modifier is applied to a class then you cannot instantiate the class using the new keyword. You can use the static keyword ... Read More

Character constants vs String literals in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 10:03:16

467 Views

Character constantsCharacter literals are enclosed in single quotes. For example, 'x' and can be stored in a simple variable of char type. A character literal can be a plain character (such as 'x'), an escape sequence (such as '\t'), or a universal character (such as '\u02C0').Certain characters in C# are ... Read More

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

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 10:01:24

102 Views

Use the isFixedSize property of Hashtable class to get a value indicating whether the Hashtable has a fixed size.The following is an example showing how to work with IsFixedSize property.Example Live Demousing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {   ... Read More

C# program to accept two integers and return the remainder

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:58:59

674 Views

Firstly, set the two numbers.int one = 250; int two = 200;Now pass those numbers to the following function.public int RemainderFunc(int val1, int val2) {    if (val2 == 0)    throw new Exception("Second number cannot be zero! Cannot divide by zero!");    if (val1 < val2)    throw new ... Read More

Advertisements