Saturday, April 20, 2024 06:58

Methods and functions parameters

April 11th, 2017

Our methods and functions can perform different actions, but sometimes, we need to offer them certain relevant data to process. We do this by using methods and functions parameters.

One of the primary goals of methods and functions is what we call code re-usability and this means we don’t have to copy and paste the same piece of code over and over, whenever we need that certain action to be performed.… Read more

Methods and functions declaration

April 9th, 2017

Methods and functions declarations is actually a three step process: declaration, implementation, call  of our method or function.

  • Declaration is the process of writing the method type, name and eventual parameters, so the program can successfully identify it.
  • Implementation of a method is writing the actual code that will be executed when the method is executed.
Read more

Functions

April 8th, 2017

Every person that ever wanted to become a programmer was at some point discouraged by one of the few things that makes programming so hard: its complexity. Whenever someone would want to code something like Skype, for instance, they would first of all feel overwhelmed about the incredibly complex task they face.… Read more

Test your knowledge! – Arrays

April 7th, 2017
Read more

Arrays of arrays

April 7th, 2017

C# allows us to have arrays of arrays, which we call jagged arrays. An array of arrays is basically an array in which each row is actually another array on its own.

This is an example of declaration for an array of arrays:

and this is how we initialize it:

Also, the arrays of the array can be one dimensional or multi-dimensional arrays, like we learned:

Finally, getting or setting the elements of an array of an array (lol, that sounds so complicated 😐 ):

Most of the times, arrays of arrays won’t be of a real use to you, there are simpler ways of doing this.… Read more

Multidimensional arrays

April 5th, 2017

In mathematics, one-dimensional arrays are also known as vectors. Some of you may still remember (riiight! 🙂 ) that multidimensional arrays are called matrices. In programming, we call multidimensional arrays any array with more than one dimension.

For instance, how would we represent the structure of a chess board programmatically?… Read more

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


Follow the white rabbit