What do I learn – C# Foundations – Week 21

This week I’m going to get more focused in review the foundations of C# in order to be prepared to have a real job interview and have all the basic technical knowledge, also this weekend I’m going to have a mock interview and have personal feedback to know which aspects I must be I focus on. 

Strings good practices

Strings good practices 

String interpolation is a technique that enables you to insert expression values into literal strings. It is also known as variable substitution, variable interpolation, or variable expansion. 

This aspect of the code is very useful for maintaining it prettier and cleaner, making the expressions more literal and with fewer characters. 

The way to use string interpolation in C# is: 

string name = “Erick”; 

Console.WriteLine($”Welcome {name}.”); 

Such much easier than the way I have to make this kind of code: 

Console.WriteLine(“Welcome ” + name + “.”); 

Also, another good practice for strings is, when we have to append a lot of strings, the proper way to make this action is using a string builder

It stresses less the processing of the result and the way to use it is: 

var result = new StringBuilder(); 


  result.Append(“something “); 


It stands for Language Integrated Query, and the main purpose is that you can use it to query any data structure, like XML, arrays, SQL Databases, etc. 

And there are 2 ways to use it, entity mode and SQL mode

Entity example: 

  var result = studentsList.Where(s => s.Name == “Erick”); 

SQL example: 

  var result = from s in studentsList where s.Name == “Erick”; 

Essentially, they make the exact same function but are an interview question that you may have in consideration. 


Asynchronous tasks are one of the more important topics in programming.  

Let’s have by example the exercise of making breakfast in the morning, you do multiple tasks at the same time, you don’t wait for the eggs to be cooked to heat the bread. 

While something is heating you can do other tasks, refactoring the code in asynchronous tasks allow the code to do multiple things without waiting for one specific task to finish to start with the next one. 

To achieve this in code, you have to declare the result type as a task: 

  function Task<bool> HeatEggs() … 

  funtions Task<bool> HeatBread() … 

And then call the functions inside an async function: 

  function async void Cook(){ 



    await Task.WhenAll(); 

Leave a Reply

Your email address will not be published. Required fields are marked *