C# for Absolute Beginners | Fiodar Sazanavets | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

C# for Absolute Beginners

teacher avatar Fiodar Sazanavets

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

6 Lessons (1h 8m)
    • 1. Introduction

      2:11
    • 2. Setting up your development environment

      2:42
    • 3. C# project explained

      14:05
    • 4. Interfaces and IO

      15:40
    • 5. Text processing

      22:53
    • 6. Building and running the application

      10:40
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

15

Students

--

Projects

About This Class

This course will teach you the fundamentals of C# in an unconventional way: by throwing you straight into the deep water and getting you to do something useful with it. So, no more "Hello World!" application!

Together, we will be building an application that will convert markdown (MD) files into HTML. By the end of the course, you will be familiar with the following:

  • Basic C# code structure

  • Flow control (for, foreach and while loops)

  • Conditional statements

  • Abstraction via interfaces

  • Reading files and writing into them

  • Processing text

  • Building and running your applications on Windows, Mac and Linux

Meet Your Teacher

Senior software developer specializing in .NET with several years of experience

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: hello and welcome to my course in this course competition your some fundamentals off C sharp programming language. But I've decided to take an unconventional approach to teaching you instead of going step by step through all the language structures I have decided to teach you by giving you to build an application, but does something useful. So by the end of this course, you probably won't know all the sea shop. However, you will know enough about it to be able to do something useful with it. We will be covering the most white. They used language structures and also will the covering how to manipulate text, how to process files. By the end of this course, you will build an application. That process is marked down files on turns to detect into html. Madam filed for months, which is usually denied by MD. Extension is a very popular sort of documentation for months get help, which is the biggest starts off cold. Depositors on the Web uses it as a standard documentation for the cold on page 10. Well, is what webpage issues. So you will be using empty file as an input on produced a similar file as the output. So instead of writing hello world application which are really boring, you will be doing something very useful and you'll be able to impress your friends with it later. You might ask No, why should you like ST Shop? Well, the truth is it's one of the most popular programming languages is definitely within the top 10 and there's a very high demand for it. The maid platforms that C sharp is used on dot net framework dot net core on model. In this tutorial, we have chosen dot net core on this is because dot net cork and run on any operating system so you don't have to be a Windows user to use this tutorial. If you're limits Komaki user, you can follow it as well. So let's get started. I'm good luck. 2. Setting up your development environment: before we can start 11 c. Sharp wellness download sort of development kid that is capable off running and compile in C sharp cold for our purpose. We will don't load dot net core from dot net score dot Microsoft does come. The space will show you the latest version of the platform. This is the version a little don't load both dot net core on Don't know framework are capable of front and I'm compiling c sharp cold. However, the reason why we've chosen dot net core is because it works on any operating system, which includes Windows. Lennox, my course don't know framework, on the other hand, on the works of Windows. So it doesn't matter what operating system you're running on. You will be able to follow all steps of this tutorial in our case. Well, it's don't load as decay because the runtime just runs the cold that has already been compiled while as decay, which stands for software. The loan on kids will enable you to actually arrive the cold and then compile it yourself. Once we don't loaded, I mean stole the dot net core. We will then need to download our code and environment. If you're Windows user, the best thing to download will be a visual studio 2000 and 19. It can be obtained from the following webpage visual studio dot Microsoft dot com On If you're just using it to learn how to called in C Sharp, just choose Community Edition Click of free download. It will be free on it will stay free forever. All you have to do is create a free Microsoft account and register. If you are using any other operation system like music. So Mark, you would need to install visual studio cold. Unlike Visual Studio 2019 original Studio called is just a called editor. So in order to compile and around your cold, you will need to use some command line commands. Visual Studio called itself Will Only Enable is to actually view and edit you called. It will still give you some hints. It will still detect syntax. Error a little promise you to fix those. However, it doesn't have as many tools as a visual studio 2019 does. Therefore, for Windows users, I will definitely recommend to use Visual Studio 2019. Once you've downloaded and installed does not score as decay. On the Accord Editor, click of the next video, I will show you how to create your first ever see sharp project. 3. C# project explained: In this video, I will show you how to create a new project in both visual studio 2019. And if you don't have it by using command line So first we will start with Visual Syria 2019. Once he opened of the software, it will give you this page. Of course, you will not have this Projects listed is because I've been using it for a while. I have these projects listed here, but you will have these buttons. Nevertheless, what you'll need to press is create new project as the project type. We will be using consul application because it is the most basic project type you can have , which is perfect petition, you see sharp. So we just click on this and click next here you can choose the folder. I've chosen two years default because in our course will be writing the software that converts markdown files too hasty. Well, I will call my project MD too. Hasty. Mel Converter one, simply created may take a while, so actually create the project. Once the project is created, it will open this window with all the project files already inserted in si shop. All in any other dot that project. The starting point of your application is a class with has static main method in C sharp method. It's something that's so you execute with parameters. We'll explain more about it later, but right now I will explain you. What's the main method is by default the stars up close in dot net. It's called program. However, you can give it in any name as long as you have a class that has a static method that is called lane. With the type of void, it will be automatically recognised as a starting point of the application. Essentially, once you launch your council application, this is where it will start from. In this case, the mother takes a single parameter. The type of the parameter is a string array, essentially string. It's just a text that's a C sharp convention. That's the data time that holds text. So, for example, in this case here, hello world is a string by the full convention. Any value that you're signed to a string variable, or parameter is enclosed in double quotation marks like it is here in this case here, have a world text is a string literal, it does not have a variable associated with it, however. Likewise, we could just do this. This will be exactly equivalent. We can use var keyword, in which case of the variable data type will be inferred from the value you give to. Because in C shop there's only one data type that has its value enclosed in double quotes, it will know that the data type is a string. When you have a over var keyword, it tells you exactly what the data type it is. As you can see here, it is a string to make it more explicit. You can just type it like this, so anybody who will be reading your cold will know instantly that it's a variable off a type string. However, in the case with our arguments, it has these square brackets at the end as well, which means that this variable is not just it off a type stream, but it's actually an array off strings. So essentially it is a collection that contains zero or more string values. Here's an example from the right. This time I will make it more explicit, so I am declaring string array and here, I can specify the length of the race. So, for example, in this case, I will only be able to hold two elements in it. So what I have declared here is a string array with two elements. Because a specified number two in square brackets here two is the capacity. I cannot have more than two elements in the array I invented to retrieve the items from the array. We'll have to specify this variable name followed by index in the square brackets index in their race starts from zero. So the first item there was hello will be out in 20 on the second ice and world will be at index one. So what we can do here, instead of specifying this literal value? But Jesse is this. So the 1st 1 values Hello, then we have the space to it and said that we had world fold by information mark. And here's an example, often up operation you can do with the data type string. This is called string concatenation. This is how you are different strings together. However, in C sharp, that's no the only way to convince innate strings. You can also do This is the dollar symbol in front of a string value and then and close any actual variables in curved brackets. Some people prefer that there's some other things you can do with strength. Well, they use plus signs and just use different string values to have them together. All use a single string value. I just insert different variables into it by using dollar sign. It's up to you. We have gone a bit off topic here because the goal of this video lecture is to show you how to create a new seashell project. We have already shown you how to create it by using Visual Studio 2019. However, if you don't have it, you have to use command line. You have access to command line anyway, even if you do have Visual Studio 2019 because command line it's part of dot net core is decay rather than visual studio itself. Nevertheless, I'll show you how to use it. The first thing you will need to do is open your command line terminal in the folder. Well, you'll be creating your new C sharp project. In my case, I have chosen courses death now what you need to type is the following dot net as one word because this isn't executable. You does. The commander you are using Council Council is the application side. Once again, it's just the same as creating consul application via visual studio. Then he is this dust and which is a shows heart full name And here your type in the name of your project MD two html converter. I'm just let it run. You can see already that it has created this project here. You can explore the project, but I've got visual studio cold open. So what I'll be able to different here is open this project to do so. I click on open folder on Go to the folder where I've created my new project, which is courses are dead and here we go. Obviously, the user interface looks a bit different, but otherwise you can edit the cold just the same way you could do it. From Visual Studio 2019. You can examine the context of your cold classes on the you can examine the project file itself. Project file is an XML file that sells compiler how to build your project. Well we're here. I'll tell you something about some others. See sharp concepts that you will need to know in C sharp, every single gold object that you create, discovered by the name space Name space is something that you use to organize your cold by convention name space is the same as your project name. However, you can choose different names space if you choose to create new folders inside your project folder and place your cold files into food. The convention is to have a name space in those cold files, the same as you have for the route. Old files. Fold by the dot full by right before the name, so you can easily arrange your cold hierarchically on the high Arctic. True, like cold structure will much exactly what the name spaces say in C Sharp. Each cold file comes with CS Extension, which stands for C Sharp, obviously, but the content of that cold file may be different Penitence what you're working with, you know, case, because it's just template without any actually useful cold. Yet there's a class called Program. Plus is a data type that you create yourself another type off custom data type is called struck. There is a difference between them. The truck is a value data type, while class is a reference data type. The difference between value and reference data types is something that will be covered later. Let's not focus on it now as well as structured classes. You can have interfaces and e news interfaces will be covered later. Interface is not really a data type. It's just a contract that tells your actual data types how they should be structured in you is just a data type that contains different categories and nothing else. It doesn't have any functional cold to execute. Another not worthy keywords that we will cover now is using he word that is usually placed on top of your cold file. Using keyboard allows your calls glasses to use various other libraries that are directly available to your cold. Those libraries may come from different assemblies that that you important to your application all. They may just come from the system libraries. After using keywords, you specify the name space under which your desires class resides. In this case here, we're just using system name Space system comes from System Library that comes as a part off dot net core. You don't have to import anything into the application to have access to it. You just need to specify using keywords to gain access to it. If I didn't have this using statement, you can see an error in the court straight away because Consul is a class that is available under system name space. Please know that I specified two slashes. Essentially, I've turned this statement into just a textual comment. So using system is not used as a cold anymore. The compiler will now treat it as just a text that somebody has put some notes into. The purpose of comments is to write some random text to make it easier for other developers to understand what you're called is doing. If it's a single line comment, you just specified two slashes. If your comment is dishpan, multiple lifestyle over. You put this statement he started with Flash Star on you Finish it with star slash on the to the to. You can specify as much. Texas You won't. This is what you do. If you want to specify a whole paragraph in the next video, we'll start doing something useful with all cold 4. Interfaces and IO: Today we will cover an important concept that is used in C Sharp on an object oriented programming. In general, it's known as obstruction in C sharp. You can achieve obstruction by either using our stocks, glasses or interfaces interfaces. I used way more often than obstruct classes in the real life, although obstruct classes do have the own use as well. In this video, we will cover an example often interface on what it's used for. One functionality off our program that we need to implement is the ability to read data from a file and to ride data back into a file. To do so, we will need to add a class that does exactly that. But that class needs to have a specific signature. This is where interface comes in. Interface is a construction block off C sharp cold that sells a particular class. What signature to use. Let's go ahead and add one. If you are not using visual studio, you can just are the file with the same name as we're gonna be doing here. But in a visual studio, the process can be done in this way. First, we'll right click on our project name, then click Add go to new item and she was interface Has a nice inside by convention in C sharp. All interfaces start with the upper case. I They're a different school of thought, but this is the person that is used the most in C sharp because we are going to be adding a class that's processes a file. We will call our interface. I filed processor. Don't keep extension of CS. So here we go. We have the same name space as our project name, and we have an earthy interface. First thing I'll do here is our access. Modify its hood. There are different access modifiers you can use In this case, I'm using internal internal means that this particular object is only visible to any other objects inside of this project. Unless I specify, that's ah specific project has access to internal objects in this class. But this is something that will cover some other day. Not in this course. All you need to be aware about for now is that access modifiers can be private, where a variable or an object can be accessed only by the parent objects on nothing else protected. We're a variable or an object can be accessed by the parent object on by any object that is derived from the parent object internal, which recovered. Here we're variable or an object can be accessed by anything within the same project within the same assembly, essentially because the project will be compiled into an assembly all public, where a variable or an object can be accessed by anything. It has a reference to your assembly. All your project interfaces in C sharp, something that's so have method signatures on the property signatures but don't have any actual logic. In our case, we will need to be able to read text from a text file unsafe text into specified text file so we'll add two methods to do so. Reading text from text file returns A textual object, which is of a type string. So we specified the object type first so well, this mothers will do if a bus full file path as a textural value into it. The idea is to access the file specified in that part. I read it on return its content as a string, and we put semicolon at them because it's just a matter signature. There's nothing in the metal itself. It will be the class that will implement the interface that will put the logic into the method. On the next to my food is of type. Avoid void in C Sharp is the data type that does not return any of data you cannot declare . Avoid variable. You can only have avoid method, so essentially avoid. Method is a method that executes some logic but does not return any value. So the idea behind it is that once you have a text that you would like to save into the file, you will pass it into this method along with the full file part. So the method that implements this interface signature we'll access the file at this file path or create one if one doesn't exist yet, and we'll save this context. The context of this variable into the file. Let's not go ahead and create a class that actually implements that interface. So in visual studio, the process is the same in visual studio cold or any other text editor. It might be different. You might even have to add it manually yourself by the file system with otherwise, which is click Add new item this time, which is close, and we'll call it filed processor. So this will creating them to class. The first thing I'll do is are the nice modify it serious once again. And now I have this symbol, this symbol the colon is using C shop next to the class name. If you want to derive your class from a base class or if you want to implement an interface in our case here we are implemented on interface. So I just type into face name and I said it. If I know I would try to compile. My solution likely can build it will fail on. The reason for that is because our class does not implement any of the Memphis defined by the signature. So the idea behind the interface is that it specifies what properties on my father's the glass should have. That only applies to public properties on my first, not private once. Also, a closet implements an interface, can have more properties, all motors than interface defiance, but it cannot have less. It has to implement every single property and as long as the method signatures on the property signatures are the same. The class is volatile. The implementation details are up to the class itself. In my clipboard, I already have some calls to populate this class with, As you can see here straight away, it has some underlines, some syntax errors, which I can fix just by ideas and the right references. So what we needed to do here is add reference to system io. Also, as you know, this here, it still doesn't implement interface properly on. The reason for that is because our public method here it's called right to file on an interface. It's called safe to file. We have two options even changed the name in the interface signature. All that changed in the method name in the class. What I'll do. It's changed the definition Indians face. However, in most of the scenarios, you'll do the other way around. And now, as you can see, I will called his valid If I build it now, As you can see, it succeeded. If one of our subsequent videos I will tell you how to build your calls from command line, but we're not ready for this just yet. When I want constant application will be fully ready. We will build it, play with it while we're here. Let's have a look at what the court is doing. So in our implementation, what we're doing here is going to the file by using in built method from system dot io library. So we're going to the file defined by this full file part variable this return string. By hovering over the method, you can see what data type it returns, and what we are doing, then is his Tomalin coding the value. That means that whatever characters this content has that aren't valid in HTML, that will be encoded. Ask HTML representation of those characters. For example, 1/4 character has a special meaning in his team Will. It provides values for attributes. So if you have quote characters in your text that are meant to be just gold characters, it will break your HTML. Therefore, we're converting the quote characters into something that HTML will understand as gold character. But that's in the plain. Text will look like something else, and that applies to any other characters that aren't valid. A sexual car access in html, the other mother is right to file so what we're doing here is string concatenation. Basically, we're combining all these elements together. One of the very end. We are adding hasty mile extension to your file. So the file that were producing will be a valid case. Female. We're saving this value until output file path variable. Let's have a look at what we're doing here. Get director and name is an inbuilt static method off a path class from sister my old library. So this bit will have only the directory name, including all the sub directors down to the director that actually contains the file. Then we are done environment specific director separator on linear system. It will be four forward slash just like it is in a Web address in the browser. But on Windows system, it will be back slash to make our calls compatible with any operating system where I just using in the build director separated character that is specific to the environment. So our code will provide the right character regardless of what operating system it runs on . Next, we're getting the name of the file, just the file itself, without any extension. So if our input file is called text dot MD. It will be now called tex dot html, because the extension that we are doing is HTML. Please know that hey, HTML files that just normal text files. They just have special characters, a special structure that is recognized by any HTML person. What we're doing, then it's converting our text to save into a stream of bite on saving it. Instill file. Here we're using using K Ward. Using keyword has a different meaning, dependent on whether it's inside the cold on top of the file, as you know already, if use in this context, using just refers the library that we need to use in this particular block of cold using inside the cold, however, has a different meaning. As soon as we reached this closing bracket, we dispose of the stream. Using only applies to glasses in C shop that implement I disposable interface. Those of the classes that use various resources that are outside off the net managed cold, for example. There are some resources that have direct access to memory or external database connections , so to make sure that we empty the memory after we're done using the resource when it's dispose of it on disposal of objects in C sharp complete, done by either calling disposed method on that particular object. Oh, and closing all the logic. Where are you using this object? In using statement as soon as of the using statement reaches the closing bracket, if the object will be disposed so we won't have any memory leak, please know that I owe insistent that I o stands for input and output. Essentially, it's a library that has anything to do with reading the files. All right, on into files. This is why we're using it in this context. 5. Text processing: In our previous video, we had a look at how files get processed by C Sharp and we also had a look at how to use interfaces and implement them within your classes. In this lesson will have a look at how to process text and there will be quite a lot to take in because of the logic that we have is fairly complex. To make a start, we will first create an interface. I will call it I text processor because we will be creating a class that's process text. Once again, this is how we do it via visual studio. But if he used another cold editor, it might be different will make his internal so we can use it to inside of our project. I'm glad one avoid method tude old convert text. We will pass a full file buff into does a parameter. Of course, the text processor will not do anything related to file itself. It will only process the text. However, as you will see later, we are using file processor inside of the text process and this is why we're passing full filed part into it. One thing to notice, as you have probably noticed those using statements up here are grayed out. Those appeared here by default. They always appear here. If you're creating new CS file by a visual studio. If a statement is great out, it means that this particular names places not used anywhere inside of your object. Therefore, we can just get rid of them. It's better to keep your cold clean. So now we will have the actual class that implements I text processing interface, and we'll call it, as you have guessed text processor. Once again, it would make it internal aunt will implement. I had text processing to face. I always have some stuff in my clipboard, So just based it in this particular statement is highlighters because we don't have their space for it. So we are just by right clicking. But otherwise Reg exe was part of regular expression name space on where it's part off link name space. I don't use the system. We can get rid of it. So as you can see, there's quite a lot to take in, so I'll go through the cold step by step. What we're doing first is declaring this private variables so as you remember from the previous lesson, private means that it's only accessible within this glass itself. It's not visible to anything else and read only he's another key word. Read only means that it can have its value, a science to it only once. I'm not just by anything but only Jerian class instance aviation, which is done via constructor here, which will cover in a minute. So there are two private variables that we're using. The 1st 1 is of type of dictionary. The 2nd 1 is off Type I file processor. So is the interface that we have created in our previous video dictionary is a type of a collection. There are also other collection types array, but we always had to look out list and so on. Dictionary is a type of A collection the Tuskegee Value purse, in this case, both key on the value. All the type string. However, you can use any values you can use any data types. The thing about dictionary is that all keys have to be unique. You cannot have duplicate keys while values can be absolutely anything as long as it's Avala string in this case. So let's have a look constructor. It's something that is used to instant. She ate an object in here. We have a single constructor that takes I file processor as a parameter because we don't have any other constructors you will have to specify. I filed processor to Winston. She ate text processor to make in the instance of it on perhaps descended into a variable. But why are we passing I five processor? You may ask, Isn't it simply an interface? It doesn't have any allergic inside of it. How is it gonna work? It's a good question. Basically, by doing things this way, we're enabling absolutely any class that implements I have filed processing to face to be passed in. So we're not dependent on the concrete implementation of file processing to face. For example, in our case here, we to have a single implementation off file processor that takes in a path to a file on the file system on is a reason or saves it. However, we might as well have another class that implements I file person to face that instead, make some Haitians API requests to a Web server and save the file onto the Web server Why are you are well, or the trees the file from a website ever just by downloading it, this glass does not care about the implementation details. All the cast about is that as long as it specifies full file part in the correct four months for particularly implementation off I'll file processor. The object that implements I file processes of husband passed into this class will do exactly what it's supposed to do with it. Now here's a dictionary. So we're populations. A dictionary with three key value purse. As you can see, a key that has to start. Carter's corresponds with a value strong enclosed in Uncle brackets. Single star character has e. M responding to it. I have deliberately left a mistake in the next key value. Papa, You see all of this? Ah, special characters in marked down text for months. This is the one that corresponds to bold text. A single star response to italic text on this of this corresponds to strike through. See if you can figure out which html element corresponds toe strike through inhe html and it will be after you to replace it with this particular HTML element. So here's our method convert text that is defined by our interface. Police know that interface never specifies access modifier. Everything that you specify in your interface is supposed to be public. But as you can see here, there quite a few other matters. That's an example off a concept that I've covered in the previous video. You can have as many medicines you would like, as long as you have at least all the methods and properties that are defined by the interface those mothers of private so they will not even be visible by anything there are only visible by the cold inside of the class itself. So this is pretty much the entry point into our class, because that is the only public method that is accessible to any cold outside of it. So here we go. Here's where we're actually reading old texts by using I file processing to face so we don't have to worry about what I'll file process. It does. All they do is just passing full file path. I'm getting the value out and it will be a string value. This is why we need full file path in this method, rejects stands for regular expression. It is a pattern language that is the reason specifically to recognized Parton's within sexual values. It's no decision of specific thing. Regular expression is something that is very universal. Going into details about how logics works will be beyond the scope of this particular lecture. You can look it up yourself. All I can say is that it looks for breaks and courage. Return characters within the text, and it uses those to split the text into paragraphs. So what do you get? On the other end is the type of a collection of the collection will consist off individual paragraphs from the text. Next, we're I sensation. A strength builder. String builder is a class that, except various textual values American continents, all the strings together to build a single string in C sharp string is a mutable data type . So having a particular string and then recalculating its value and saving it into the same variable is not efficient, recommended way of doing it, especially if the logic of building a strength spans multiple methods is by using string builder. You just keep adding strength to it, and at the end, you call build on it. Here's an example of control. Fluency show this logic here is known as for each loop, for each applies to something that implements I innumerable interface and see shop, for example. It's applicable to lists, but it's not applicable to our race. I raise the process differently. You can still run a loop on it, but it's a different kind of look, which we will cover in a minute. What we're doing here is looking at the collection of paragraphs on the process in each paragraph individually. So the first thing I would do is making sure that the paragraph has and your letters in it . Oh, any symbols? If it doesn't have any, we just kind of this paragraph on may use this key. Words continue. If he used inside the loop continue, we'll just jump to the next element off the loop. The next paragraph, and it will not execute any of the logic down here and for each loop will carry on until the last paragraph Husband processed. So for every paragraph, it goes through these steps. First, it caused this mattered three times. All of the schools are pretty much the same, apart from one thing. The last parameter into the call is different. Starts with three, then with two with one. Let's examine this method. So essentially, what we're doing here is checking with a particular paragraph. Particular block of text is a header in a market down language. Head is a marked with the cash character in front of the text, and here is an example off a loop that we would use to eat away through elements often array. But we're not doing it here. Over there. Here is just making a number of its orations defined by this promise a head, a type. So if it's three, then we just constructing a string that consists of three cash characters, if it's to them, is just too. If it's one, it's a single hash character. This is how four loop works. First, we define an invariable. Usually it's an insurgent. There's a semicolon. We eat a rate until the value of this incident. Mr this particular condition, it's up to you what condition you specify. But the most common way off using for loop is to reiterate until the value off I or whatever you call your first variable rich is a particular value. So while I is less than Heather type into specified the Lupul carry on and then where is in this operator? Plus plus means that the value inside of I variable increments by one. So let's have a look of the logic. Let's imagine that head attack is three. So we start with I equals zero. We checked with I. His lesson Heather type. So zero is less than three. So we execute the loop ones, then on the next iteration. Because we executed this, the value of I we'll do one one. It's still less than three. So we append another harsh character to string builder in the next iteration, the value of eyes, too still less than three. So we still upend yet another harsh character to the string on the next iteration. The value off I is three, which does not satisfy this condition. So this is where we stop executing the loop, and we don't do anything else with the string. As a result, we have three hash characters in the string. Now this is where we're building it. So String Builder has accepted harsh character three times on another call to string it creates a string value that contains those three can hash characters. And here's an example of one of the methods that C Sharp has to money to a strings and to check the values we're checking whether this particular paragraph starts with a particular number of harsh characters. If it doesn't, then we just don't execute anything inside of this. If statement, if it does, we were the control inside of the East statement. So the first thing that we do is at this break element, which inside it's a line break between our header, which is quite a logical thing to do. Of them went close. Our paragraph. It's a cage pulled by the number specified in the head of type Aunt were executed. Strings replace essentially any instances off head America. A specific number of hush characters will be removed from this strength. I would do it for her. The three headed soon, Heather one. We started on the bigger number first to make sure that we don't miss identify items with Head three as head of one, and then once we processed all the head of types that we support down to three, we process the paragraph if it's relevant, are you can never get our method. Be the scrolling down or just breast enough. 12. So here it is. The first thing that we do is checking whether it is indeed the paragraph. If it does not start with indicator that is a header, then it is a bar graph. In our case, it probably will always be paragraph because we already processed headers by that time. So once again we are executing for each loop. But this time we are executing its own dictionary. Dictionary has feels keys on values Well, we are basically executing its own keys. This is how you retrieve a value from a dictionary. Specify the variable name that holds the dictionary on its square brackets. You specify whatever value you store as your key. In this case, for each of the alterations, it will be one of these values that gets returned. So we're just some processing to the paragraph data, and then we enclose it into P tug, which stands for paragraph. Upend Line is a method of string builder that inserts this particular textual value as a separate line, so it as New line encourage return characters to the end of the previous lines. If I go to this method now, this is what it's doing. So once again we're making check whether it's a program for not, which is probably redundant, but we want to be sure on. If particular paragraph contains this impetus, we just go ahead and execute this logic because in MD there has to be even number off markdown tugs enclosing a particular text. But you want to make you the bold italic or cross it over. Therefore, we are making sure that there's an even number off those occurrences on. We are doing so by using this module ISS operator, modular operator. The same is division, but it calculates the remains of so first, the device whole numbers by each other. I don't Whatever is left is a marginalised. In our case, we're account of the occurrences of particular characters. Then we're divided by two aunt. If the remainder is zero, that means it's even number, and we're good to process it, and this is how we're counting occurrences. And that's another loop type that we haven't covered yet. So first we're passing the park of text, and then there's the part in which was a key from our dictionary. First was specified. These variables count is the initial count, which is zero because we haven't processed anything yet. We haven't found anything yet. I'm kind of index's zero as well. Please remember that in C sharp, as in almost all programming languages, if you are iterating through array or text index, start from zero. So the first element in your array is element number zero. Likewise, the first letter in your text is a letter number zero. Then we change in the current index value to the first occurrence off this particular pattern. Index off isn't inbuilt. Function on string index off will always return positive value, with the exact index off a particular pattern within the text. If it couldn't find any, it will return minus one as the value. And this is an operator that we're using to increase the value of current index. So we found the index. Let's say the first occurrence was at index number five, so them whatever come in this is were implemented by the length of the pattern. So we know to start looking from further within the text next time within the next generation on this loop will carry on execution until it cannot find any more occurrences of this particular pattern. In this particular text of the of the end, it will just return count which will will implement every single time we find occurrence off this pattern. So once we have established, both count it is, um if the count nicely devised by zero, we apply the tag replacement, which is done by this method here. I'm just the promises. So input tug is the key from our dictionary on output Tug, if you remember, here is the value. So if the key is this than the algebra tag will do this, this is how we do with the replacement. So once again, where using a very similar logic in the wild loop to go through the text and to find the occurrences of it. Now this is where we are using module is once again, this is done to make sure that we distinguish between even and odd occurrences of a particular tug. If it's an old number, it's an open in tired. So we just inside it as a Z. If it's an even number, we add in this slush to it because in the HTML, clothes and talks have forward slashes after the first uncle bracket. And then at the end, we just get rid of all the old tugs. So what we're left with is pure hash Tamil and no more marked down stuff. Let's go. Boxes of beginning. So we have processed all the paragraphs we have inserted values into our string Builder of the end. We just insert another break to the end of our text on Finally, we save what we have created until file. So if you remember in final processor, there's a method right to file. Now, this is where we're using it now. This is where we're converting our string builder into string, So we've ended up with pure HTML. Now, this won't get saved into the new file, But please don't forget about this. See if you can figure out what Doug Mr going here. What does this do in MD file for a month on what is hasty molecule and thank you for your attention 6. Building and running the application: And now finally, we have reached the most interesting part. Well, no building run our program. But before we do so we need to make some modifications to our program until CS file and change the logic of the entry point of the program. I have some cold in the clipboard, which are based in here, So let me walk you through what is doing this time. We're using men without arguments. Main message can have promises or may just be empty. It doesn't matter. It will still be recognized as the entry point into the program. We have several of these entries. Consul is a static class, which is a part of system named Space on the right line will make this text appear as a separate line. So when you look at the program, it will go through every one of these statements and will output every single one of this lines in the window. The information is self explanatory. It basically tells you what the program is all about. Here's where the interesting part starts. We are making a new instance off text processor aren't into these constructor, Remember? Constructed from the previous lecture we're passing on new instance of file processor. So this is an example off how we can assign absolutely any class that implements I filed processing to face to this value. After that, we're waiting for the council output council dot Red Line Method will pose execution until he's type something into the input line and press answer. So essentially, it expects you to type full file part as the instruction Saiz. And then we're running Convert text method. Now you might be wondering, What does this block of cold mean? So I say to try at the beginning, and then it ends with Koch. There's a class of type exception here as well. Try bloke will enable you to cash any Earth. If, for example, you specify some file part that does not point at the Lalit file. Your problem will throw in era. But instead of crashing, it will catch this error and it will output. Hear what the error is. Exception is just a stunt is class in C sharp that contains era information. So if we explore it, it contains items such as message, which will give you the error message source, which will tell you whether error came from a stock trace, which basically will tell you of the medicine name spaces that you could follow to find out in more detail where the error came from. And then, regardless of whether we had any errors or not, it will output. Press any key to exit message this method here council dot reid key. We'll wait for any key press because it's the last statement off the method. The application will stop execution right here. Unhittable exit. Now let's build application and see it in action. So before you build it, you need to set it up as a startup project because we currently have only one project in our solution. It is a start, a project by the fold. But if you have more, you would need to select this particular one without only applies to visual Studio House Dude, by other Memphis, I will show you in a minute. In visual studio. There's a play button here which will build on the run application, but otherwise you could just drive click on either solution. All project on either click, build or rebuild Rebuild will do clean before it does build. It will clean all the outputs from the previous bills before it builds a new version of it . So if we press this button ah, windows should pop up and then we are all program has not started. So it gives the instruction off exactly what to do, what we're gonna be doing here. It's coping this path. I don't have an example of m D file in the folder. If I right click on it, here's the raw, empty structure. So essentially this one here because he's got one harsh will be intemperance. It's as a major head in the one with two hashes will be interpreted as subheading. Case two in his Tamil, the line with three hushes will be interpreted as head and which is even lower in hierarchy . I was involved the rest of the text that just paragraphs. So I wanted to type with me. MZ press enter now. As you can see here we have a new file created called Read me dot html. If I view it as a text, you can see that it has converted everything into HTML on If we compare them side by side, you could see exactly that H one elements have been created from single hash lines. Hace two elements have been recreated from double harsh lines and so on. There's a break element inserted between the headings. Please know that your code does not execute as a text. When I click build, I compiled the cold into executable assemblies of those gets placed within the bin folder. So that is our program. Bin folder does not camp with a solution. By default, I can safely deleted. It's not part of the cold base, because every time I built the project or the solution, it creates new bin folder anyway. So now I will show you how to build on around the application. If you don't have visual Studio 2019 first of all, I will open my command line terminal within the folder where the project is located. And now I will type dot net build, followed by the project name. You can choose to build a solution with the extension off S l N. The solution files aren't actually monetary project files of the ones that matter. If you choose to build solution file, every single project under that solution will be built. If it's just to build a project file, then just that project will be built on nothing else. So if I executed now, it has given me the outputs of the build operation. It has recreated Blaine folder with exactly the same files we had before. Now I will show you how to run it. So whichever folder contains the outward off your build, you can just never get to it on open command line Terminal in the the main assembly, But we have created is the one that has the same name as our project name and has extension of deal on to run it. All you have to do is type dot net, followed by the assembly name. And as you can see, it's exactly the same as the window we've been launching from Visual Studio 2019. And while we're here, I will show you some other interesting things you can do with your project. In visual studio. There's a concept off break points. Essentially, if I place break point on any line by clicking in the margins of the cold file, the execution of the court will stop. Well, it reaches this brake point so I can examine the data in different variables. Let's try it now. So here we go. We pose the execution, Aunt. If we had any variables defined, we will be able to view their values. This process is known as the bargain, and this is why we're building our application in debug mode. If you do it in the bag mold, every single line will be available to you to place a break point on. If you're ready to release it to production, you do it in the release mold. Although you can still use the bugger functionality. If you're building it in the release mold, it will not be as good. There's no guarantee that your break point will actually be hit because release mold optimizes your cold saw a particular line of cold maybe optimized away. So remember debug its what development release is with production, and that concludes our course. I hope you enjoyed it. I'm good luck feels