- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34485 Articles for Programming
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
17K+ Views
To find the length of an array, use the Array.Length() method.ExampleLet us see an example − Live Demousing System; class Program { static void Main(){ int[] arr = new int[10]; // finding length int arrLength = arr.Length; Console.WriteLine("Length of the array: "+arrLength); } }OutputLength of the array: 10Above, we have an array −int[] arr = new int[10];Now to find the length, we used the Length() method −int arrLength = arr.Length;
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
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 { static void Main(string[] args) { Console.WriteLine("The size of int is {0}", sizeof(int)); Console.WriteLine("The size of int is {0}", sizeof(char)); Console.WriteLine("The size of short is {0}", sizeof(short)); Console.WriteLine("The size of long is ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
If you want to pass arguments by command line, then use command line arguments in C# −When we create a program in c#, static void main is used and we can see the arguments in it .class HelloWorld { static void Main(string[] args) { /* my first program in C# */ Console.WriteLine("Hello World"); Console.ReadKey(); }The string[] args is a variable that has all the values passed from the command line as shown above.Now to print those arguments, let’s say we have an argument, “One” −Console.WriteLine("Length of the arguments: "+args.Length); ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
17K+ Views
To empty an array in C#, use the Array Clear() method: The Array.Clear method in C# clears i.e.zeros out all elements.In the below example, we have first considered an array with three elements −int[] arr = new int[] {88, 45, 76};Now we have used the Array.Clear method to zero out all the arrays −Array.Clear(arr, 0, arr.Length);Let us see an example of Array.Clear method in c# −Example Live Demousing System; class Program { static void Main() { int[] arr = new int[] {88, 45, 76}; Console.WriteLine("Array (Old):"); foreach (int val in arr) ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
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; class Program { static void Main() { string[] arr = { "one", "two", "three", "four", "five" }; string[] arrCloned = arr.Clone() as string[]; Console.WriteLine(string.Join(", ", arr)); Console.WriteLine(string.Join(", ", arrCloned)); Console.WriteLine(); } ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
246 Views
Type casting is converting one type of data to another type. The two forms are −Implicit type conversion − These conversions are performed by C# in a type-safe manner. For example, are conversions from smaller to larger integral types and conversions from derived classes to base classes.Explicit type conversion− These conversions are done explicitly by users using the pre-defined functions. Explicit conversions require a cast operator.The following are the built-in type conversion methods −Sr.NoMethod & Description1ToBooleanConverts a type to a Boolean value, where possible.2ToByteConverts a type to a byte.3ToCharConverts a type to a single Unicode character, where possible.4ToDateTimeConverts a type ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
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 the same line −int[] runs = new int[5] {125, 173, 190, 264, 188};The following is an example displaying how to declare, initialize and display an array −Example Live Demousing System; namespace Program { class Demo { static void Main(string[] args) { int[] ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
720 Views
Multi-dimensional arrays are also called rectangular array. You can define a 3-dimensional array of integer as −int [ , , ] a;Let us see how to define a two-dimensional array −Int[, ] a = new[3, 3]The following is an example showing how to work with a multi-dimensional i.e. rectangular array in C# −Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { int[, ] a = new int[3, 3]; a[0, 1]= 1; a[0, 2]= 2; ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
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; ... variableN; // member methods method1(parameter_list) { // method body } method2(parameter_list) { // method body } ... methodN(parameter_list) { // method body } ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
A member function of a class is a function that has its definition or its prototype within the class definition similar to any other variable. It operates on an object of the class of which it is a member, and has access to all the members of a class for that object.The following is an example of a member function −public void setLength( double len ) { length = len; } public void setBreadth( double bre ) { breadth = bre; }The following is an example showing how to access member functions in C#.Example Live Demousing System; namespace ... Read More