C-SHARP - 2.9 Comments
Hello everyone and welcome to this new video Today we will see the notion of commentary in C#. First of all, what is a comment in programming? A comment is an indication that we will put in our code in order to have a more readable code for you but also for other developers who will work with you on corporate or other projects. The comments will therefore help to better understand your code. And these comments will be totally ignored when you run the program. The compiler will not take this into account, it is as if it does not exist. Small clarification in case you ask yourself the question. Comments will not impact your code. Many developers neglect comments when in reality they are really very useful It may be that you go on vacation, off or other And it's been a while since you haven't taken a look at your project Or for example that you are in a group with other developers, it may be very difficult to understand what other developers have done While a little comment of the style here I created a function to Program Now let's go to Visual Studio to see how to make comments in C#. We are now on Visual studio to show you how to make comments in C#. To do this, it's very simple just place yourself on a line and make two slashes // and then your whole line becomes a comment. As you can see, the comments are colored. In most programming languages, comments are in green. Another indication, when you make a comment it must be clear and precise like that when you are going to reread your code it will be easier to understand it but also not only, because you may be doing a group project, so it is important to write precise and useful comments for other developers. For example, here, I will write next to the Console function.ReadLine() what this function does in my program So I will write "We ask the user to enter a number" Here too I can write: the "Conversion of numbers of string types to int" And we add them. These are small indications that will allow us to better understand our code, it is very important. Here you see, it's very simple to make comments. But there is another way to make comments in C#. And this time we will be able to write comments on several lines. So to do this, you just have to type /* and now you can write a comment on several lines, you can type what you want And to do it but you just have to type */ It's very useful if you want to put a piece of your code in a comment to do story tests that the compiler ignores it or that if you need to explain a piece of I'll see you next time in a new video.