Tuesday, May 11, 2021 13:39

Iteration through the elements of an array

April 5th, 2017

Iteration through the elements of an array is basically the way we access all the elements of an array, in an automated way. The first type of loop we will exemplify is the For loop.

It is always a good practice to use a for loop whenever you deal with an array or any other structure with indices.… Read more

Accessing the elements of arrays

April 4th, 2017

As I was explaining in a previous post, arrays can be seen as a building (the array itself) with apartments (the elements of the array), each identified by an apartment number (the indices or the array elements). So, accessing the elements of arrays is done through their elements indices, just like finding an address is done through the apartment number inside a building.… Read more

Initialization of arrays

March 31st, 2017

Like any other variables, arrays must be initialized before we can access and use an element of that array. In C#, initialization of arrays is done automatically with default initial values. For numeral types, the default initialization value is 0, False for bool type, null for reference types, etc.… Read more

Declaration of arrays

January 19th, 2017

When we are dealing with declaration of an array, you should always remember that arrays in C# are fixed length. Their length is set at the time we instantiate them, it determines the total number of elements that they can store, and it cannot be changed/resized anymore.… Read more

Arrays

January 18th, 2017

You’ve made it this far! Well done! Starting with arrays, we can already say we have a very basic knowledge of C# programming. Still a long path ahead of us, but we are no longer n00bs. We now know the fundamental things of (almost) any programming language and we can write basic programs.… Read more

Nested loops

January 17th, 2017

Nested loops are programming concepts consisting of two or more loops placed one into the other. The innermost loop is executed the most times, while the outermost, the least times. This is because the inner loops have to perform all of their cycling for every cycle of their next outer loop.… Read more

Continue operator

January 16th, 2017

In the last article, we spoke about the Break operator being used to immediately stop a loop and continue the execution with the statements that follow after the loop. The Continue operator works somehow in the same way, with the only difference that it will only make the execution skip the current iteration of the loop.… Read more

Break operator

January 16th, 2017

The break operator is used whenever we want to end a loop immediately, even before ending its execution in a natural way. Whenever the Break operator is met, the execution of the loop is immediately stopped and the program continues executing the first instruction that follows after the loop.… Read more

Foreach loop

January 14th, 2017

The foreach loop is significantly more simpler than the For loop, but it’s also harder for the readers of this blog, since it’s based on concepts we haven’t learned yet. For this reason, i will simply tell you that a foreach loop was designed to iterate through all elements of an array, list or any other collection of elements that implement IEnumerable interface.… Read more

For loop

January 14th, 2017

For loop is a kind of repeating code construct which is a bit more complex than the previous types of loops we learned so far. On the other hand, they can solve more complicated tasks, with less code involved.

The syntax of the For instruction is the following:

When the program repeats (cycles) the instructions for a certain number of times, you will usually use a variable called control variable, which indicates how many times you executed the instructions.… Read more


Follow the white rabbit