### C# Arrays And Everything You Need To Know About Them

C# arrays are data structures for storing multiple items of the same type. This guide shows you how to use different varieties of arrays.

Filter by Category

- C# Tutorial(85)
- C# Image Processing(69)
- Morphological Processes(20)
- Image Processing(16)
- Image Restoration and Reconstruction(16)
- Image Segmentation(13)
- C# Data Structures And Algorithms(11)
- Color Image Processing(8)
- Frequency Domain Filtering(8)
- Image Noise(6)
- Grayscale Morphology(5)
- Thresholding(4)
- Order-Statistic Filters(4)
- Mean Filters(4)
- Sorting Algorithms(4)
- Morphological Reconstruction(3)
- Edge Detection(3)
- Simple Lists(2)
- RGB to HSI Color Model(2)
- Adaptive Filters(2)
- Tone and Color Corrections(2)
- Linked Lists(2)
- Stacks(1)
- Queues(1)
- Point Detection(1)
- Line Detection(1)
- C# Arrays(1)
- Region Segmentation Using Superpixels(1)
- Region Segmentation With K Means Clustering(1)
- Region Splitting And Merging(1)
- Sorted Lists(1)
- Region Growing Segmentation(1)
- Digital Image Watermarking(1)
- Using Color In Image Segmentation(1)
- Social Games(1)
- Bandreject Filters(1)
- Bandpass filters(1)
- Notch Filters(1)
- Landing Pages(1)
- Intensity Slicing and Color Coding(1)
- Color Slicing(1)
- Histogram Processing Color Images(1)
- Color Image Smoothing And Sharpening(1)
- C# Basics(1)

Back to Latest Articles
###
C# Arrays And Everything You Need To Know About Them

###
How To Make SLIC Superpixel Algorithm With C#

###
How To Make K Means Clustering Algorithm With C#

###
How To Make Region Splitting And Merging Algorithm – C#

###
How To Make Region Growing Algorithm With C#

###
How To Make Adaptive Thresholding Algorithm With C#

###
How To Make Multilevel Thresholding Algorithm With C#

###
How To Make Otsu Thresholding Algorithm With C#

###
How To Make A Basic Global Thresholding Algorithm – C#

###
How To Make Canny Edge Detection Algorithm With C#

C# Basics

C# arrays are data structures for storing multiple items of the same type. This guide shows you how to use different varieties of arrays.

Region Segmentation Using Superpixels

SLIC superpixel segmentation is a modern operation for reducing irrelevant detail for shortening computational time in further processing.

Region Segmentation With K Means Clustering

K means clustering is a optimization method of partitioning an image by measuring Euclidean distances between pixels and cluster means.

Region Splitting And Merging

Region splitting and merging is a texture segmentation operation, where we use descriptors such as local mean intensity and standard deviation

Region Growing Segmentation

Region growing segmentation is a process, with which we can extract regions from image based on the properties of pixels inside them.

Thresholding

Adaptive thresholding operation computes thresholds for each pixel locally and therefore segments images more accurately.

Thresholding

Multilevel thresholding is an extension of Otsu's method of thresholding, which basically works for an arbitrary number of thresholds.

Thresholding

Otsu thresholding is a global thresholding method, with which we find optimal threshold intensity to ensure the maximum separability.

Thresholding

This tutorial demonstrates how to get optimal threshold value for basic global thresholding operation for segmentation in image processing.

Edge Detection

Canny edge detection process is an edge detection based segmentation operation in image processing for accurately extracting edges.

C# Arrays And Everything You Need To Know...

C#, spoken Csharp, programming language offers us three different variations of arrays, which I’m going to describe in this post. But first of all, I’m going to talk about what arrays are even good for.

I’m sure that, as a developer, you’ve must have encountered a problem, where you needed to store a collection of data within your application. Even though there are many ways of doing that, using an array is probably the easiest and most natural one possible.

Arrays are data structures, which can hold many values of the same type. For example, you can create arrays of generic types like int, string or custom types you make yourselves.

In this guide, I’m going to show you how to use different variations of arrays. Therefore, you might get to consider other options to solve your problem with better efficiency.

However, C# arrays of all varieties have one drawback in common. They’re all limited to have the number of items inside, which we specify when we initialize the array. This can cause problems, when we want to add data continuously into a collection.

This is the simplest form of an array, which we can use to store data in a single dimension. Furthermore, when we initialize the array, we only need to specify its size. Or in other words, how many items it’s going to hold.

```
//declare single dimensional array of integers
int[] numbers;
```

We can see how to declare a simple array of integers in the code section above. In order to use this array, we also need to initialize it.

```
//initialize single dimensional array of integers
int[] numbers = new int[3];
```

For example above, we created an empty array of integers, which can hold 3 integer values. Furthermore, if we initialize it without specifying what the values are, the values will default to 0.

We can change or call the numbers inside, by specifying their index number. Index numbers start from 0 and end at array size minus one. In the example I set above, first number will have the index of 0, second the index of 1 and last the index of 2.

We can define values when we initialize the array in a couple of different ways.

```
//define values inside array using indexes
numbers[0] = 4;
numbers[1] = 2;
numbers[2] = 6;
//initialize and define values at once
int[] numbers = new int[]{4, 2, 6};
int[] numbers = {4, 2, 6};
```

As you can see, if you initialize an array with already defined values it should store, you don’t need to define its size.

Multi dimensional array is similar to single dimensional array I described above. The only difference is that we need to specify its size in 2 or more dimensions. This will create an array, that can store values in multiple dimensions.

```
//declare and initialize empty multi dimensional array
int[,] multi = new int[2,3];
//declare and initialize multi dimensional array with predefined values
int[,] multi = new int[,] =
{
{3, 2, 1},
{6, 4, 5}
};
```

Each of these values can be changed or called by specifying the index numbers for each dimension.

```
//access a number in the array
int number = multi[1,0]
```

The number in the example above will access number 6 from the preceding example array.

Jagged arrays are basically arrays of arrays. In other words, they are single dimensional arrays, that hold arrays instead of values like integers or strings.

Their advantage to multi dimensional arrays is that the arrays, which it holds, can be of different length to one another.

However, in order to make them work, we need to initialize each array inside separately.

```
//declare and initialize jagged array
int[][] jagged = new int[2][]
//initialize also the arrays it stores
jagged[0] = new int[3]
jagged[1] = new int[2]
```

Example above shows how you can store arrays of different sizes inside the jagged array. You can also see jagged arrays at work in a Fourier Transform project for converting images into frequency domain.

Hopefully, this post helped you gain a better understanding of arrays and how to use them.

You can also download the example project I made, where you can see how it works in practice.

## Comments