Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I determine the size of my array in C#
Firstly, set an array −
int[] arr = {6, 3, 8, 4};
Now, use the Length property to get the size of the array −
arr.Length
Let us see the complete code −
Example
using System;
namespace Demo {
public class Demo {
public static void Main(string[] args) {
int[] arr = {6, 3, 8, 4};
Console.WriteLine("Array...");
foreach (int i in arr) {
Console.Write(i + " ");
}
Console.WriteLine("
Size of Array: "+arr.Length);
}
}
}
Output
Array... 6 3 8 4 Size of Array: 4
Advertisements