Tutorialspoint

How to define methods in C#?

Ankith Reddy
Answered on 7th Aug, 2018

A method is a group of statements that together perform a task. Every C# program has at least one class with a method named Main. When you define a method, you basically declare the elements of its structure. The syntax for defining a method in C# is as follows − ... Read More

Why we do not have global variables in C#?

Samual Sam
Answered on 7th Aug, 2018

C# does not have global variables and the scope resolution operator used in C++ for global variables is related to namespaces. It is called global namespace alias. If you have a type that shares an identifier in a different namespace, then to identify them using the scope resolution operator. ... Read More

How to define jagged arrays in C#?

karthikeya Boyini
Answered on 7th Aug, 2018

A Jagged array is an array of arrays. You can define a jagged array named points of type int as − int [][] points; Let us now see how to initialize it − int[][] points = new int[][]{new int[]{10, 5}, new int[]{30, 40}, ... Read More

How to define dynamic data types in C#

Maheshwari Thakur
Answered on 7th Aug, 2018

You can store any type of value in the dynamic data type variable. Type checking for these types of variables takes place at run-time. C# 4.0 introduced the dynamic type that avoids compile time type checking. The following is the syntax for declaring a dynamic type − dynamic <variable_name> ... Read More

How to define custom methods in C#?

Samual Sam
Answered on 7th Aug, 2018

To define a custom method in C#, use the following syntax − <Access Specifier> <Return Type> <Method Name>(Parameter List) { Method Body } The following are the various elements of a method − Access Specifier − This determines the ... Read More

What is the operator precedence in C#?

Ankith Reddy
Answered on 7th Aug, 2018

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Operator precedence determines the grouping of terms in an expression. This affects evaluation of an expression. Certain operators have higher precedence than others do; for example, the multiplication operator has higher precedence than the ... Read More

What is the method for sorting a list in C#?

Samual Sam
Answered on 7th Aug, 2018

The sort a list in C#, use the Sort() method. Let us first create a list − List<string> myList = new List<string>(); Now add elements − myList.Add("Audi"); myList.Add("BMW"); myList.Add("Chevrolet"); myList.Add("Hyundai"); Use the Sort() method to sort the list − ... Read More

Working with Hashtable and Dictionary in C#

George John
Answered on 7th Aug, 2018

Hashtable Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection. Some of the commonly used methods in Hashtable class are − Sr.No. Method & Description 1 public ... Read More

What is the maximum possible value of an integer in C# ?

karthikeya Boyini
Answered on 7th Aug, 2018

The maximum possible value of an integer is 2, 147, 483, 647. The following are the datatypes of C# with the maximum and minimum value − Type Represents Range Default Value bool Boolean value True or False False byte 8-bit unsigned ... Read More

Working with DateTime in C#

Samual Sam
Answered on 7th Aug, 2018

The DateTime class in C# is used to represent date and time in C#. The following are some of the properties of DateTime in C# − Sr.No Property & Description 1 Date Gets the Date component 2 Day Gets the day ... Read More

Why is the Main() method use in C# static?

Chandu yadav
Answered on 7th Aug, 2018

The Main method states what the class does when executed and instantiates other objects and variables. A main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class. ... Read More

How is an array declared in C#?

karthikeya Boyini
Answered on 7th Aug, 2018

To declare an array in C#, you can use the following syntax − datatype[ ] Name_of_array; Here, datatype is used to specify the type of elements in the array. [ ] specifies the size of the array. Name_of_array specifies the name of the array. ... Read More

Where do we use scope Resolution Operator (::) in C#?

Maheshwari Thakur
Answered on 7th Aug, 2018

In C++ the scope resolution operator i.e. :: 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 operator. For example, to reference System.Console class, use the ... Read More

Why do we use comma operator in C#?

Samual Sam
Answered on 7th Aug, 2018

Comma operator in C# can be used as a separator in method argument list. You can also use it is an operator in a for statement. The following is an example showing using a comma operator in a for statement for initialization − for (int i = ... Read More

What is the RemoveAt method in C# lists?

karthikeya Boyini
Answered on 7th Aug, 2018

The RemoveAt() method in C# is used to remove an element in a list at a position you set. Firstly, set elements in the list − var subjects = new List(); subjects.Add("Physics"); subjects.Add("Chemistry"); subjects.Add("Biology"); subjects.Add("Science"); ... Read More

Advertisements
Loading...
Unanswered Questions View All