Karthikeya Boyini has Published 2383 Articles

How to use the Clone() method of array class in C#?

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

The Clone() method in C# is used to clone the existing array.Firstly, set the array to be cloned.string[] arr = { "Web", "World"};Now clone the array created above using the array.Clone() method.string[] arrClone = array.Clone() as string[];Let us see the complete example.Exampleusing System; class Program {    static void Main() ... Read More

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

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 12:33:05

547 Views

The GetLength gets a 32-bit integer that represents the number of elements in the specified dimension of the Array.First, set the array.int[, ] arr = new int[20, 30];For a specified dimension of the array, set the index in the GetLength() method like −Arr.GetLength(1);Example Live Demousing System; class Program {    static ... Read More

How to create or reset counters with JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 12:25:14

705 Views

To create counters, use the counterReset property in JavaScript. You can try to run the following code to create or reset one or more counters with JavaScript −ExampleLive Demo                    h2:before {             counter-increment: section; ... Read More

What are abstract classes in C#?

karthikeya Boyini

karthikeya Boyini

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

260 Views

Abstract classes contain abstract methods, which are implemented by the derived class. The derived classes have more specialized functionality.The following is an example showing the usage of abstract classes in C#.Example Live Demousing System; namespace Demo {    abstract class Shape {       public abstract int area();    } ... Read More

What are Add, Remove methods in C# lists?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 12:17:39

678 Views

The List is a collection in C# and is a generic collection. The add and remove methods are used in C# lists for adding and removing elements.Let us see how to use Add() method in C#.Example Live Demousing System; using System.Collections.Generic; class Program {    static void Main() {     ... Read More

How to create a tuple with string and int items in C#?

karthikeya Boyini

karthikeya Boyini

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

285 Views

Firstly, set two items in the tuple.Tuple tuple = new Tuple(20, "Tom");Now check for first item in the tuple, which is an integer.if (tuple.Item1 == 20) {    Console.WriteLine(tuple.Item1); }Now check for second item in the tuple, which is a string −if (tuple.Item2 == "Tom") {    Console.WriteLine(tuple.Item2); }The following ... Read More

How to create custom attributes in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 12:08:35

202 Views

Custom attributes that can be used to store declarative information and can be retrieved at run-time.Let us see how to declare custom attribute.[AttributeUsage ( AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] public class DeBugInfo : System.AttributeFor our example, let us construct a custom attribute named ... Read More

What is the scope resolution operator in C#?

karthikeya Boyini

karthikeya Boyini

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

937 Views

The scope resolution operator in C# has a different meaning as compared with C++. In C++ the :: is used for global variables, whereas in C# it is related to namespaces.If you have a type that share an identifier in different namespace, then to identify them use the scope resolution ... Read More

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

karthikeya Boyini

karthikeya Boyini

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

83 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

171 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

Advertisements