C-SHARP - 3.8 Condition
Hello everyone and welcome to this new video. In this video we will discuss the notion of condition in C#. With the conditions, we will get to the heart of what programming is the algorithm. Behind this term algorithm actually hides the term logic. Until now, most of the scripts we've coded together haven't been very smart. They are asked to display a sentence and it displays it without asking the slightest question. At the end of this section, you will be able to create programs that will react differently depending on the circumstances. A small example, let's imagine we create an e-Commerce website and a user would like to connect to his account, here it is a case where we will use the conditions. The user will enter his identifiers and his password, if the password corresponds to the one which is in the database then the user can connect otherwise he is displayed incorrect password, you see? So be very careful because it is with these conditions that we will be able to start writing really more advanced scripts. Now let's get to the heart of the matter. What is the purpose of the conditions here? It is to test a condition to be able to carry out an action or not according to the result of this test. So to give you an example. Imagine that a young man goes to the cinema, and to be able to access the cinema, you must be at least 18 years old. So here we find our condition and our action. The condition is that this young man must be at least 18 years old and the action is that he is given access to the cinema. If yes, he fulfills this condition then he can enter, otherwise access is refused. You will notice here, a condition returns either yes or no or more precisely True or False. Indeed a condition, when it will be evaluated will return what is called a boolean. What is a boolean? We saw it in a previous video but I'll remind you It's either True or False or in French True or False. So it is thanks to that, that we will be able to decide whether or not our script must perform an action according to the result that a condition will return to us. Like the case above of the cinema of the young man that we will translate in line of code in order to better understand we have here age which must be greater than or equal to 18 Small parenthesis we find our comparison operators that we had in a previous video. we will often use them for the conditions or the loops that we will see later. In the next video, we will see how to use one or more conditions to execute an action depending on the result returned to us. See you right away on Visual Studio. we will often use them for the conditions or the loops that we will see later. In the next video, we will see how to use one or more conditions to execute an action depending on the result returned to us. See you right away on Visual Studio. we will often use them for the conditions or the loops that we will see later. In the next video, we will see how to use one or more conditions to execute an action depending on the result returned to us. See you right away on Visual Studio.