Karthikeya Boyini has Published 2383 Articles

How is an array initialized in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 11:00:30

78 Views

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.Firstly, declare an array −int[] rank;But declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to ... Read More

Cloning in C#

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:52:59

282 Views

Cloning in C# is useful if you want to clone an array. The Clone() method in C# is used to create a similar copy of the array. C# has the Clone method and ICloneable interface.Let us see an example to clone an array using the Clone() method −Example Live Demousing System; ... Read More

How to use sizeof() operator to find the size of a data type or a variable in C#

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:51:08

229 Views

The sizeof() datatype returns the size of a data type. Let’s say you need to find the size of int datatype −sizeof(int);For double datatypesizeof(double);Let us see the complete example to find the size of various datatypes −Example Live Demousing System; namespace Demo {    class Program {   ... Read More

What is the Capacity property of an ArrayList class in C#?

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

The capacity property in ArrayList class gets or sets the number of elements that the ArrayList can contain.Capacity is always greater than count. For capacity property −arrList.CapacityThe default capacity is 4. If 5 elements are there, then its capacity is doubled and would be 8. This goes on.You can try ... Read More

What are the member variables of a class in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:42:05

3K+ Views

A class is a blueprint that has member variables and functions in C#. This describes the behavior of an object.Let us see the syntax of a class to learn what are member variables − class class_name {    // member variables     variable1;     variable2;   ... Read More

How to define a single-dimensional array in C Sharp?

karthikeya Boyini

karthikeya Boyini

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

236 Views

An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type stored at contiguous memory locations.To define a single-dimensional array −int[] runs = new int[10];Let us now initialize the array in ... Read More

How to write the first program in C#?

karthikeya Boyini

karthikeya Boyini

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

443 Views

The following is the first program in C# programming −Example Live Demousing System; namespace MyHelloWorldApplication {    class MyDemoClass {       static void Main(string[] args) {          // display text          Console.WriteLine("Hello World");          // ... Read More

How to declare and initialize a dictionary in C#?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.To declare and initialize a Dictionary −IDictionary d = new Dictionary();Above, types of key and value are set while declaring a dictionary object. An int is a type of key and string is a ... Read More

How to declare and initialize constant strings in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 10:27:16

9K+ Views

To set a constant in C#, use the const keyword. Once you have initialized the constant, on changing it will lead to an error.Let’s declare and initialize a constant string −const string one= "Amit";Now you cannot modify the string one because it is set as constant.Let us see an example ... Read More

What are reserved keywords in C#?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

Keywords are reserved words predefined to the C# compiler. These keywords cannot be used as identifiers. If you want to use these keywords as identifiers, you may prefix the keyword with the @ character.In C#, some identifiers have special meaning in the context of code, such as get and set ... Read More

Advertisements