← Back
IAmTimCorey September 14, 2026 33m

Command Line Arguments in C# Apps - What are args and how do we use them?

Read full transcript 27 segments
  1. You probably know that command line You probably know that command line arguments exist in .NET apps, but have arguments exist in .NET apps, but have arguments exist in .NET apps, but have you ever tried to use them? In this you ever tried to use them? In this you ever tried to use them? In this video, we're going to look at what video, we're going to look at what video, we're going to look at what command line arguments are, how to pass command line arguments are, how to pass command line arguments are, how to pass them into a C app, and how to properly them into a C app, and how to properly them into a C app, and how to properly group them and use them. Now, if you group them and use them. Now, if you group them and use them. Now, if you don't know me, my name is Tim Corey and don't know me, my name is Tim Corey and don't know me, my name is Tim Corey and I help people become better developers, I help people become better developers, I help people become better developers, especially around C andnet topics. I especially around C andnet topics. I especially around C andnet topics. I have over a thousand videos here on this have over a thousand videos here on this have over a thousand videos here on this channel to help you on your journey. For channel to help you on your journey. For channel to help you on your journey. For those of you who are looking for those of you who are looking for those of you who are looking for specific topics, I offer dozens of specific topics, I offer dozens of specific topics, I offer dozens of training courses on devforge.com. training courses on devforge.com. training courses on devforge.com. There you'll find master courses on There you'll find master courses on There you'll find master courses on Unity game development, C, and web Unity game development, C, and web Unity game development, C, and web development, although the individual development, although the individual development, although the individual courses covering Git, Azure, SQL, and courses covering Git, Azure, SQL, and courses covering Git, Azure, SQL, and much more. The proceeds of those course much more. The proceeds of those course much more. The proceeds of those course sales are what funds the free content sales are what funds the free content sales are what funds the free content like this. You'll also find even more like this. You'll also find even more like this. You'll also find even more free content on devforge.com, so free content on devforge.com, so free content on devforge.com, so definitely check it out. Okay, let's definitely check it out. Okay, let's definitely check it out. Okay, let's jump into Visual Studio. You can do this jump into Visual Studio. You can do this jump into Visual Studio. You can do this in uh VS Code, you can do this in Jet in uh VS Code, you can do this in Jet in uh VS Code, you can do this in Jet Brains Writer. It doesn't really matter.

  2. Brains Writer. It doesn't really matter. Brains Writer. It doesn't really matter. We're going to use a console app. And We're going to use a console app. And We're going to use a console app. And everything will be basically the same. everything will be basically the same. everything will be basically the same. So, we're going to say console app. And So, we're going to say console app. And So, we're going to say console app. And let's just call this uh CLI let's just call this uh CLI let's just call this uh CLI demo and CLI demo app. And we're say net 10. We are not going And we're say net 10. We are not going to use top level. I'm sorry. We're not to use top level. I'm sorry. We're not to use top level. I'm sorry. We're not going to turn off top level statements. going to turn off top level statements. going to turn off top level statements. This this checkbox always gets me This this checkbox always gets me This this checkbox always gets me confused. Um, we're gonna leave the top confused. Um, we're gonna leave the top confused. Um, we're gonna leave the top level statements as they are, which is level statements as they are, which is level statements as they are, which is going to add a layer of confusion. I'm going to add a layer of confusion. I'm going to add a layer of confusion. I'm going to show you about that in just a going to show you about that in just a going to show you about that in just a minute. Okay. And we're going to hit minute. Okay. And we're going to hit minute. Okay. And we're going to hit create. So, when you create this create. So, when you create this create. So, when you create this product, you get just the, you know, product, you get just the, you know, product, you get just the, you know, oneline hello world console app. Um, and oneline hello world console app. Um, and oneline hello world console app. Um, and that's it. So, let's even get rid of that's it. So, let's even get rid of that's it. So, let's even get rid of that. And now we have an app that has that. And now we have an app that has that. And now we have an app that has nothing. In fact, this would actually be nothing. In fact, this would actually be nothing. In fact, this would actually be a problem because there's no uh starting a problem because there's no uh starting a problem because there's no uh starting point of the app. But we want to pull in point of the app. But we want to pull in point of the app. But we want to pull in the command line arguments. Now, let me the command line arguments. Now, let me the command line arguments. Now, let me just show you real quick. If I add the just show you real quick. If I add the just show you real quick. If I add the solution, I'm going to add a new project solution, I'm going to add a new project solution, I'm going to add a new project console app. Let's call it console one console app. Let's call it console one console app. Let's call it console one is fine. We're not going to keep it long is fine. We're not going to keep it long is fine. We're not going to keep it long term, but we're going to say do not use term, but we're going to say do not use term, but we're going to say do not use top level statements. And we're going to top level statements. And we're going to top level statements. And we're going to create what used to be the starter for a create what used to be the starter for a create what used to be the starter for a console app where you have your console app where you have your console app where you have your namespace, you have your internal class namespace, you have your internal class namespace, you have your internal class program, your static void main, and then program, your static void main, and then program, your static void main, and then your hello world. But notice right here, your hello world. But notice right here, your hello world. But notice right here, string array args.

  3. string array args. string array args. This is the one area where the top level This is the one area where the top level This is the one area where the top level statements I think have a slight miss statements I think have a slight miss statements I think have a slight miss and that is I would love for them to put and that is I would love for them to put and that is I would love for them to put at the top here some type of we're at the top here some type of we're at the top here some type of we're bringing in arcs. um that's just implied bringing in arcs. um that's just implied bringing in arcs. um that's just implied instead of actually showing it to you. instead of actually showing it to you. instead of actually showing it to you. The rest of the stuff doesn't matter. So The rest of the stuff doesn't matter. So The rest of the stuff doesn't matter. So the rest of the stuff is just not needed the rest of the stuff is just not needed the rest of the stuff is just not needed uh for 98% of all cases and so got rid uh for 98% of all cases and so got rid uh for 98% of all cases and so got rid of it uh in top level statements. So the of it uh in top level statements. So the of it uh in top level statements. So the only thing be kind of different is if only thing be kind of different is if only thing be kind of different is if you create a method u here it' be a you create a method u here it' be a you create a method u here it' be a actual full method whereas here is actual full method whereas here is actual full method whereas here is what's called a local method because what's called a local method because what's called a local method because it's actually inside of static void it's actually inside of static void it's actually inside of static void main. So um it's a bit different. This main. So um it's a bit different. This main. So um it's a bit different. This is kind of off topic. I just want to is kind of off topic. I just want to is kind of off topic. I just want to make sure I point this out. But this make sure I point this out. But this make sure I point this out. But this right here is what we're going to be right here is what we're going to be right here is what we're going to be tapping into today is this the arcs. So tapping into today is this the arcs. So tapping into today is this the arcs. So let's even get rid of console app just let's even get rid of console app just let's even get rid of console app just so we um don't get confused with what so we um don't get confused with what so we um don't get confused with what we're doing.

  4. we're doing. we're doing. Okay. So that string array args is still Okay. So that string array args is still Okay. So that string array args is still available here. So if I were to say uh available here. So if I were to say uh available here. So if I were to say uh for and let's do a for loop that says for and let's do a for loop that says for and let's do a for loop that says args.length. args.length. args.length. So notice that args is available and I So notice that args is available and I So notice that args is available and I can say console right line. Let's do a can say console right line. Let's do a can say console right line. Let's do a string interpolation and we're going to string interpolation and we're going to string interpolation and we're going to say um I we'll say colon and then the say um I we'll say colon and then the say um I we'll say colon and then the value of i in the args. So args at value of i in the args. So args at value of i in the args. So args at position i. So this will give us the the position i. So this will give us the the position i. So this will give us the the number. So 0 1 2 3 of the argument as number. So 0 1 2 3 of the argument as number. So 0 1 2 3 of the argument as well as what the value is for that well as what the value is for that well as what the value is for that argument. So let's talk about command argument. So let's talk about command argument. So let's talk about command line arguments. Now we can we can build line arguments. Now we can we can build line arguments. Now we can we can build this project. And if I were to run this this project. And if I were to run this this project. And if I were to run this right now, it wouldn't really work real right now, it wouldn't really work real right now, it wouldn't really work real well. Um because we're not passing in well. Um because we're not passing in well. Um because we're not passing in any arguments. Let's change that. Let's any arguments. Let's change that. Let's any arguments. Let's change that. Let's right click on our project and go to right click on our project and go to right click on our project and go to open file explorer. Um what I'm going to open file explorer. Um what I'm going to open file explorer. Um what I'm going to do is I'm going to rightclick in here do is I'm going to rightclick in here do is I'm going to rightclick in here and say open terminal.

  5. and say open terminal. and say open terminal. So that just makes life easier for me. I So that just makes life easier for me. I So that just makes life easier for me. I am now in the terminal where this app am now in the terminal where this app am now in the terminal where this app is. But that's not really where I want is. But that's not really where I want is. But that's not really where I want to be totally because if I if I say well to be totally because if I if I say well to be totally because if I if I say well let's leave it here for now. We'll let's leave it here for now. We'll let's leave it here for now. We'll actually open up um another one. Let's actually open up um another one. Let's actually open up um another one. Let's grab this. We'll copy it and then we'll grab this. We'll copy it and then we'll grab this. We'll copy it and then we'll say cd and paste that in there. If I say cd and paste that in there. If I say cd and paste that in there. If I take away the um take away the um take away the um there you go. I take away the angle there you go. I take away the angle there you go. I take away the angle bracket at the end. Okay. So in this one bracket at the end. Okay. So in this one bracket at the end. Okay. So in this one I'm going to go a bit further. Let's go I'm going to go a bit further. Let's go I'm going to go a bit further. Let's go ls for list directory and say cd bin and ls for list directory and say cd bin and ls for list directory and say cd bin and then it's uh cd debug then it's uh cd debug then it's uh cd debug and then it's cdnet10.0 and then in here we can see that there and then in here we can see that there is the cli demo.exe. That's our actual is the cli demo.exe. That's our actual is the cli demo.exe. That's our actual console application. Okay. So now we've console application. Okay. So now we've console application. Okay. So now we've got both places the the root of our got both places the the root of our got both places the the root of our project as well as where the exe is. So, project as well as where the exe is. So, project as well as where the exe is. So, let's start with the root of our let's start with the root of our let's start with the root of our project. We're going to say net run and project. We're going to say net run and project. We're going to say net run and then we're going to say dash dash then we're going to say dash dash then we're going to say dash dash and let's do this again. Sorry. Uh dash and let's do this again. Sorry. Uh dash and let's do this again. Sorry. Uh dash and a space and then we can start and a space and then we can start and a space and then we can start putting parameters in. So, dash dash putting parameters in. So, dash dash putting parameters in. So, dash dash um hello um hello um hello and then putting in quotes world. Okay.

  6. and then putting in quotes world. Okay. and then putting in quotes world. Okay. So this is going net run is going to run So this is going net run is going to run So this is going net run is going to run our application first. So that's that's our application first. So that's that's our application first. So that's that's the first step there. But then we have the first step there. But then we have the first step there. But then we have this dash dash that says hey I'm going this dash dash that says hey I'm going this dash dash that says hey I'm going to send in some command line arguments to send in some command line arguments to send in some command line arguments now. [snorts] And then we can send the now. [snorts] And then we can send the now. [snorts] And then we can send the command line arguments in. I know it's a command line arguments in. I know it's a command line arguments in. I know it's a little weird to have the dash dash with little weird to have the dash dash with little weird to have the dash dash with nothing after it. Um but the thing after nothing after it. Um but the thing after nothing after it. Um but the thing after is actually all the rest of our is actually all the rest of our is actually all the rest of our parameters. So, we have this dash- parameters. So, we have this dash- parameters. So, we have this dash- hello, which is the in theory the key hello, which is the in theory the key hello, which is the in theory the key and then the world with the value. Um, and then the world with the value. Um, and then the world with the value. Um, but we're going to see it's not quite but we're going to see it's not quite but we're going to see it's not quite how it works. Um, and maybe have another how it works. Um, and maybe have another how it works. Um, and maybe have another parameter doesn't have any value. The parameter doesn't have any value. The parameter doesn't have any value. The parameter is called turbo. You know, parameter is called turbo. You know, parameter is called turbo. You know, make put our app in turbo mode. Um, and make put our app in turbo mode. Um, and make put our app in turbo mode. Um, and another one might be uh test. We're another one might be uh test. We're another one might be uh test. We're going to say this is a test. going to say this is a test. going to say this is a test. Okay. So, lots of parameters there. Okay. So, lots of parameters there. Okay. So, lots of parameters there. Let's actually make this a little bigger Let's actually make this a little bigger Let's actually make this a little bigger so you can see it. So we run this, we'll so you can see it. So we run this, we'll so you can see it. So we run this, we'll see that it says, remember, we're we're see that it says, remember, we're we're see that it says, remember, we're we're looping through all the arguments. Well, looping through all the arguments. Well, looping through all the arguments. Well, argument at position zero is dash- argument at position zero is dash- argument at position zero is dash- hello. This right here argument position hello. This right here argument position hello. This right here argument position one is world. Notice no double quotes.

  7. one is world. Notice no double quotes. one is world. Notice no double quotes. So it's all that. The next one is So it's all that. The next one is So it's all that. The next one is d-turbo. The next is dash- test. And the d-turbo. The next is dash- test. And the d-turbo. The next is dash- test. And the next is this is a test. Also not in next is this is a test. Also not in next is this is a test. Also not in double quotes. But notice because of the double quotes. But notice because of the double quotes. But notice because of the double quotes, we can have spaces in double quotes, we can have spaces in double quotes, we can have spaces in there without a problem. So this is how there without a problem. So this is how there without a problem. So this is how you pass command line arguments into our you pass command line arguments into our you pass command line arguments into our app. Now I did the net run version. app. Now I did the net run version. app. Now I did the net run version. Let's come over here and call our .exe Let's come over here and call our .exe Let's come over here and call our .exe which is called uh CLI demo. So I can which is called uh CLI demo. So I can which is called uh CLI demo. So I can we're in PowerShell space we're in PowerShell space we're in PowerShell space CLI demo. And then we can pass in some CLI demo. And then we can pass in some CLI demo. And then we can pass in some arguments. So I don't have to do a dash arguments. So I don't have to do a dash arguments. So I don't have to do a dash dash. I can just say uh test this is a dash. I can just say uh test this is a dash. I can just say uh test this is a test like so and now the first argument test like so and now the first argument test like so and now the first argument is d- test and the second one is this is is d- test and the second one is this is is d- test and the second one is this is a test. So it's only when we do net run a test. So it's only when we do net run a test. So it's only when we do net run we have to have this extra dash dash in we have to have this extra dash dash in we have to have this extra dash dash in there. That's one thing to note but there. That's one thing to note but there. That's one thing to note but we're getting values now passed into our we're getting values now passed into our we're getting values now passed into our application from the command line.

  8. application from the command line. application from the command line. Now, for demo purposes, this is a pain Now, for demo purposes, this is a pain Now, for demo purposes, this is a pain to go over here and and run this, to go over here and and run this, to go over here and and run this, especially since we're not getting good especially since we're not getting good especially since we're not getting good debugging because we're running the debugging because we're running the debugging because we're running the application. We're not um attaching the application. We're not um attaching the application. We're not um attaching the Visual Studio debugger. So, you can't Visual Studio debugger. So, you can't Visual Studio debugger. So, you can't put break points in, etc. There's a way put break points in, etc. There's a way put break points in, etc. There's a way to fix this. So, let's come over here to fix this. So, let's come over here to fix this. So, let's come over here and right click on our project, go to and right click on our project, go to and right click on our project, go to properties, and then come down here to properties, and then come down here to properties, and then come down here to debug and say open debug launch profile debug and say open debug launch profile debug and say open debug launch profile UI. Notice the the wrapping here. That's UI. Notice the the wrapping here. That's UI. Notice the the wrapping here. That's just because I have a a large font on just because I have a a large font on just because I have a a large font on for recording purposes. So in here, for recording purposes. So in here, for recording purposes. So in here, command line arguments. command line arguments. command line arguments. We can say um d-hello We can say um d-hello We can say um d-hello world and then we can put a new line if world and then we can put a new line if world and then we can put a new line if you want or just put a space after. you want or just put a space after. you want or just put a space after. Doesn't really matter. I'll put a new Doesn't really matter. I'll put a new Doesn't really matter. I'll put a new line. We'll say d-turbo. line. We'll say d-turbo. line. We'll say d-turbo. And we'll do d- test. And this is a And we'll do d- test. And this is a And we'll do d- test. And this is a test. So you have, you know, three test. So you have, you know, three test. So you have, you know, three different parameters. different parameters. different parameters. Okay. So we close that out. And now Okay. So we close that out. And now Okay. So we close that out. And now notice it added a properties folder notice it added a properties folder notice it added a properties folder under there. The launch settings.json.

  9. under there. The launch settings.json. under there. The launch settings.json. If we open that up, you'll see the If we open that up, you'll see the If we open that up, you'll see the command line name or command name is command line name or command name is command line name or command name is project and the command line arguments. project and the command line arguments. project and the command line arguments. There you go. And notice all the escape There you go. And notice all the escape There you go. And notice all the escape characters because the fact we have characters because the fact we have characters because the fact we have double quotes in here, which is why double quotes in here, which is why double quotes in here, which is why typing out like this is a pain. Whereas typing out like this is a pain. Whereas typing out like this is a pain. Whereas if you use the u the properties window, if you use the u the properties window, if you use the u the properties window, it's a whole lot easier. Okay. So now if it's a whole lot easier. Okay. So now if it's a whole lot easier. Okay. So now if we just run our application, we just run our application, we just run our application, we get the hello world turbo test. This we get the hello world turbo test. This we get the hello world turbo test. This is a test. Cool. So we've got a bit more is a test. Cool. So we've got a bit more is a test. Cool. So we've got a bit more um they can play around with without um they can play around with without um they can play around with without having to um you know drop into our having to um you know drop into our having to um you know drop into our console or our our terminal or something console or our our terminal or something console or our our terminal or something else. else. else. Now I do want to point out one thing and Now I do want to point out one thing and Now I do want to point out one thing and that is if we run this app we're that is if we run this app we're that is if we run this app we're separating out in a different properties separating out in a different properties separating out in a different properties hello and world and test and this is a hello and world and test and this is a hello and world and test and this is a test. There is a way to make this those test. There is a way to make this those test. There is a way to make this those two connect into one. If we go to two connect into one. If we go to two connect into one. If we go to properties I don't recommend this but properties I don't recommend this but properties I don't recommend this but you can under debug launch profile we you can under debug launch profile we you can under debug launch profile we can say let's just do one. We'll say can say let's just do one. We'll say can say let's just do one. We'll say hello equals world. If we run this now, hello equals world. If we run this now, hello equals world. If we run this now, we'll see that hello equals world and we'll see that hello equals world and we'll see that hello equals world and notice no double quotes. Um, those are notice no double quotes. Um, those are notice no double quotes. Um, those are connected. So, just know you can do that connected. So, just know you can do that connected. So, just know you can do that if you want. Again, I don't recommend if you want. Again, I don't recommend if you want. Again, I don't recommend it, but it is possible to do. Um, I'm it, but it is possible to do. Um, I'm it, but it is possible to do. Um, I'm going to show you why I don't recommend going to show you why I don't recommend going to show you why I don't recommend it. U, but it in general, it's not great

  10. it. U, but it in general, it's not great it. U, but it in general, it's not great command line argument uh formatting command line argument uh formatting command line argument uh formatting practices. So you talk about like practices. So you talk about like practices. So you talk about like running actual.net, running actual.net, running actual.net, you don't see that. So instead, what you don't see that. So instead, what you don't see that. So instead, what we're going to do is we're going to kind we're going to do is we're going to kind we're going to do is we're going to kind of, you know, elevate this game a bit. of, you know, elevate this game a bit. of, you know, elevate this game a bit. But first, what if you had, I don't But first, what if you had, I don't But first, what if you had, I don't know, a a different let's let's come know, a a different let's let's come know, a a different let's let's come over here and say control shift A. Let's over here and say control shift A. Let's over here and say control shift A. Let's say helper say helper say helper and make a static class. So we're and make a static class. So we're and make a static class. So we're keeping this really simple. We'll make keeping this really simple. We'll make keeping this really simple. We'll make it public it public it public static class helper. And um we're going static class helper. And um we're going static class helper. And um we're going to have a static method public static to have a static method public static to have a static method public static void um I don't know uh test args. Okay. So in here I want to access the Okay. So in here I want to access the args. And if I were to do args it's not args. And if I were to do args it's not args. And if I were to do args it's not available. So args at position zero just available. So args at position zero just available. So args at position zero just not available. So what do I do? Well, not available. So what do I do? Well, not available. So what do I do? Well, there is an option. We're going to say there is an option. We're going to say there is an option. We're going to say uh let's just do var for now. Args. I'm uh let's just do var for now. Args. I'm uh let's just do var for now. Args. I'm going to call the same thing. There's a going to call the same thing. There's a going to call the same thing. There's a debate whether you call it something debate whether you call it something debate whether you call it something different or not. We'll talk about why.

  11. different or not. We'll talk about why. different or not. We'll talk about why. Uh but if you're in a different place Uh but if you're in a different place Uh but if you're in a different place than the start of your application, you than the start of your application, you than the start of your application, you don't have access to that string array don't have access to that string array don't have access to that string array arcs. But you can get it using arcs. But you can get it using arcs. But you can get it using environment.get environment.get environment.get command line arcs. Now, I will tell you command line arcs. Now, I will tell you command line arcs. Now, I will tell you this is slightly different than the this is slightly different than the this is slightly different than the actual command line arcs. We're gonna actual command line arcs. We're gonna actual command line arcs. We're gonna see why. Let's just copy this. I need an see why. Let's just copy this. I need an see why. Let's just copy this. I need an arc so we can just copy and paste this arc so we can just copy and paste this arc so we can just copy and paste this in without a problem. So, let's do the in without a problem. So, let's do the in without a problem. So, let's do the same thing that we're doing over here. same thing that we're doing over here. same thing that we're doing over here. And let's just do this. Let's put a um And let's just do this. Let's put a um And let's just do this. Let's put a um console right line at the beginning that console right line at the beginning that console right line at the beginning that says this is from says this is from says this is from um string array args. um string array args. um string array args. I'm going to put a couple of um console I'm going to put a couple of um console I'm going to put a couple of um console right lines and I'm going to put a right lines and I'm going to put a right lines and I'm going to put a console right line says this is from um console right line says this is from um console right line says this is from um environment.get environment.get environment.get get command line arcs get command line arcs get command line arcs and then down here we'll say helper and then down here we'll say helper and then down here we'll say helper which is going to bring in the using which is going to bring in the using which is going to bring in the using directive uh helper dot uh test args directive uh helper dot uh test args directive uh helper dot uh test args like so and that prints right to console like so and that prints right to console like so and that prints right to console already. So let's run this again.

  12. already. So let's run this again. already. So let's run this again. And now notice that 0 through 4 this one And now notice that 0 through 4 this one And now notice that 0 through 4 this one is 0 through five. Why? because the very is 0 through five. Why? because the very is 0 through five. Why? because the very first one is the path to our first one is the path to our first one is the path to our application. You might say, "Wait, Tim, application. You might say, "Wait, Tim, application. You might say, "Wait, Tim, it's a CLI demo.dll." it's a CLI demo.dll." it's a CLI demo.dll." Yep, it is. That's hownet works. The Yep, it is. That's hownet works. The Yep, it is. That's hownet works. The .exe is basically just a wrapper. So, .exe is basically just a wrapper. So, .exe is basically just a wrapper. So, the CLI demo.dll, that's the the full the CLI demo.dll, that's the the full the CLI demo.dll, that's the the full path from the C drive, the full path to path from the C drive, the full path to path from the C drive, the full path to my running application. That's the one my running application. That's the one my running application. That's the one thing that environment.get get command thing that environment.get get command thing that environment.get get command line args does for you that just string line args does for you that just string line args does for you that just string array args does not which means if array args does not which means if array args does not which means if you're trying to line them up you're off you're trying to line them up you're off you're trying to line them up you're off by one which is always fun when you have by one which is always fun when you have by one which is always fun when you have arrays to have off by one errors. So arrays to have off by one errors. So arrays to have off by one errors. So just note those two are not quite the just note those two are not quite the just note those two are not quite the same but they're close. So if you're same but they're close. So if you're same but they're close. So if you're going to be dealing with environment.get going to be dealing with environment.get going to be dealing with environment.get get command line args which you can get get command line args which you can get get command line args which you can get from basically anywhere in your from basically anywhere in your from basically anywhere in your application including from class application including from class application including from class libraries and all the rest. Uh just know libraries and all the rest. Uh just know libraries and all the rest. Uh just know that the position zero is the path the that the position zero is the path the that the position zero is the path the full path to your application which full path to your application which full path to your application which means for actual args you'd want to means for actual args you'd want to means for actual args you'd want to start at position one if there is one.

  13. start at position one if there is one. start at position one if there is one. Now couple of things here I want to talk Now couple of things here I want to talk Now couple of things here I want to talk about while we're looking at this. This about while we're looking at this. This about while we're looking at this. This is a string array. Whether you're doing is a string array. Whether you're doing is a string array. Whether you're doing it from git command line args or from it from git command line args or from it from git command line args or from args, either way, it's a string array. args, either way, it's a string array. args, either way, it's a string array. Every value is a string. So even if you Every value is a string. So even if you Every value is a string. So even if you pass in a number, it's still a string pass in a number, it's still a string pass in a number, it's still a string representation of a number. It's not a representation of a number. It's not a representation of a number. It's not a number itself. So you would have to do number itself. So you would have to do number itself. So you would have to do some kind of cast and or parse and make some kind of cast and or parse and make some kind of cast and or parse and make sure that you're parsing with try parse sure that you're parsing with try parse sure that you're parsing with try parse and and doing all the error checking for and and doing all the error checking for and and doing all the error checking for that. So that's one thing. The other that. So that's one thing. The other that. So that's one thing. The other thing is these two are different. Um but thing is these two are different. Um but thing is these two are different. Um but this is only available at the the root this is only available at the the root this is only available at the the root of your application unless you were to of your application unless you were to of your application unless you were to then store it in a long running then store it in a long running then store it in a long running variable. Okay. So just want to point variable. Okay. So just want to point variable. Okay. So just want to point that out in the fact that that out in the fact that that out in the fact that environment.get command line args is a environment.get command line args is a environment.get command line args is a different length.

  14. different length. different length. Also note that either way it's a string Also note that either way it's a string Also note that either way it's a string array that is going to be not null. It array that is going to be not null. It array that is going to be not null. It will never arg. So if you pass nothing in what happens So if you pass nothing in what happens is it has a array length of zero. It's is it has a array length of zero. It's is it has a array length of zero. It's empty but it's an empty array. not a empty but it's an empty array. not a empty but it's an empty array. not a null array. So you can still check for null array. So you can still check for null array. So you can still check for it. In fact, if we were to come back to it. In fact, if we were to come back to it. In fact, if we were to come back to our um our demo here and let's do a net our um our demo here and let's do a net our um our demo here and let's do a net run with no parameters. Okay, so it's still running with the Okay, so it's still running with the launch settings.json. That's awesome. Um launch settings.json. That's awesome. Um launch settings.json. That's awesome. Um so what we'd have to do is um I can get so what we'd have to do is um I can get so what we'd have to do is um I can get rid of those. Um let's rid of those. Um let's rid of those. Um let's let's do it this way. This should work. let's do it this way. This should work. let's do it this way. This should work. Um if we just do dot slash uh cli demo, Um if we just do dot slash uh cli demo, Um if we just do dot slash uh cli demo, I don't believe it passes in the launch I don't believe it passes in the launch I don't believe it passes in the launch parameters. It doesn't. Um so by running parameters. It doesn't. Um so by running parameters. It doesn't. Um so by running it the actual executable, we can see it the actual executable, we can see it the actual executable, we can see that the this is from string array args.

  15. that the this is from string array args. that the this is from string array args. Nothing. And this is from environment Nothing. And this is from environment Nothing. And this is from environment command line. It has just the path. command line. It has just the path. command line. It has just the path. That's it. So either way, you're not That's it. So either way, you're not That's it. So either way, you're not going to have a problem with a null going to have a problem with a null going to have a problem with a null reference exception to args or to uh get reference exception to args or to uh get reference exception to args or to uh get command line arcs. command line arcs. command line arcs. Okay. So now let's talk about ways to Okay. So now let's talk about ways to Okay. So now let's talk about ways to make this a bit better. All right. So make this a bit better. All right. So make this a bit better. All right. So let's close this out. Let's come we can let's close this out. Let's come we can let's close this out. Let's come we can close out a help or two. And we're going close out a help or two. And we're going close out a help or two. And we're going to get back to just um let's just to get back to just um let's just to get back to just um let's just comment that out. In fact, let's comment comment that out. In fact, let's comment comment that out. In fact, let's comment all of this because I want to leave this all of this because I want to leave this all of this because I want to leave this here for you. By the way, the source here for you. By the way, the source here for you. By the way, the source code is available. There's a link in the code is available. There's a link in the code is available. There's a link in the description to get that email to you. description to get that email to you. description to get that email to you. Um, what we're going to do is we're Um, what we're going to do is we're Um, what we're going to do is we're going to um let's create a new going to um let's create a new going to um let's create a new dictionary that's going to kind of parse dictionary that's going to kind of parse dictionary that's going to kind of parse these for us a bit better. So what we're these for us a bit better. So what we're these for us a bit better. So what we're going to do is we're going to say var going to do is we're going to say var going to do is we're going to say var options equals uh new dictionary of type options equals uh new dictionary of type options equals uh new dictionary of type string and string and string and nullable string and we're going to say nullable string and we're going to say nullable string and we're going to say um string comparer is going to be um string comparer is going to be um string comparer is going to be ordinal ignore case. So we're going to ordinal ignore case. So we're going to ordinal ignore case. So we're going to ignore casing when we're dealing with um ignore casing when we're dealing with um ignore casing when we're dealing with um looking for keys. So if if you pass in looking for keys. So if if you pass in looking for keys. So if if you pass in lowercase Name E for name or if you pass lowercase Name E for name or if you pass lowercase Name E for name or if you pass in capital N lowerase AME, it will still in capital N lowerase AME, it will still in capital N lowerase AME, it will still match. Okay, that's kind of important.

  16. match. Okay, that's kind of important. match. Okay, that's kind of important. Okay, so what we're going to do is we're Okay, so what we're going to do is we're Okay, so what we're going to do is we're going to parse this string array args going to parse this string array args going to parse this string array args and we're going to do it in a way that and we're going to do it in a way that and we're going to do it in a way that makes it more useful for key value makes it more useful for key value makes it more useful for key value pairs. Again, dictionary holds key value pairs. Again, dictionary holds key value pairs. Again, dictionary holds key value pairs. So, we're going to say four. pairs. So, we're going to say four. pairs. So, we're going to say four. We're going to do the same thing. Uh, We're going to do the same thing. Uh, We're going to do the same thing. Uh, args.length. And then we're going to say um if And then we're going to say um if uh args at position [clears throat] uh args at position [clears throat] uh args at position [clears throat] i i i starts with starts with starts with and we'll say the dash character and we'll say the dash character and we'll say the dash character um equals false. um equals false. um equals false. then we're going to continue. then we're going to continue. then we're going to continue. Okay. So, what we're doing here, we're Okay. So, what we're doing here, we're Okay. So, what we're doing here, we're going to look for parameters, but we going to look for parameters, but we going to look for parameters, but we we're going to insist that every key has we're going to insist that every key has we're going to insist that every key has to start with a dash dash. Now, we're to start with a dash dash. Now, we're to start with a dash dash. Now, we're only looking for the first dash, but only looking for the first dash, but only looking for the first dash, but we're going to insist on every parameter we're going to insist on every parameter we're going to insist on every parameter has to start with a dash. So, it can't has to start with a dash. So, it can't has to start with a dash. So, it can't uh and if you really want to be enforce uh and if you really want to be enforce uh and if you really want to be enforce this, you could do a dash dash and not this, you could do a dash dash and not this, you could do a dash dash and not do a char. You could do a string. Um, do a char. You could do a string. Um, do a char. You could do a string. Um, but either way, enforce that it starts but either way, enforce that it starts but either way, enforce that it starts with that dash dash. That way we know with that dash dash. That way we know with that dash dash. That way we know that um you know you're not passing in that um you know you're not passing in that um you know you're not passing in weird data that's going to mess things weird data that's going to mess things weird data that's going to mess things up. We're expecting the the the dash up. We're expecting the the the dash up. We're expecting the the the dash dashy first. Now I point out where this dashy first. Now I point out where this dashy first. Now I point out where this is going to get um even even kind of is going to get um even even kind of is going to get um even even kind of help us in other ways. I'm going to show help us in other ways. I'm going to show help us in other ways. I'm going to show you in a minute. First, let's go on to

  17. you in a minute. First, let's go on to you in a minute. First, let's go on to um string key equals args at position um string key equals args at position um string key equals args at position iTrim iTrim iTrim start start start and we're going to trim the dashes off. and we're going to trim the dashes off. and we're going to trim the dashes off. Now, trim start with just one d one char Now, trim start with just one d one char Now, trim start with just one d one char is actually going to look for is there is actually going to look for is there is actually going to look for is there another char and get rid of that one as another char and get rid of that one as another char and get rid of that one as well if there's two dashes. Okay, one well if there's two dashes. Okay, one well if there's two dashes. Okay, one thing I forgot to mention here, continue thing I forgot to mention here, continue thing I forgot to mention here, continue here. What that does is if we find out here. What that does is if we find out here. What that does is if we find out that the the arg does not start with a that the the arg does not start with a that the the arg does not start with a dash, we're going to go on to the next dash, we're going to go on to the next dash, we're going to go on to the next item in our array. We're not going to item in our array. We're not going to item in our array. We're not going to we're not going to do any more of this we're not going to do any more of this we're not going to do any more of this code down below in the four. We're going code down below in the four. We're going code down below in the four. We're going to go to the next iteration. So that's to go to the next iteration. So that's to go to the next iteration. So that's what continue does in a for loop. Okay. what continue does in a for loop. Okay. what continue does in a for loop. Okay. So now we're since it is it does start So now we're since it is it does start So now we're since it is it does start with a dash then we're going to trim off with a dash then we're going to trim off with a dash then we're going to trim off those dashes and put that as the key. those dashes and put that as the key. those dashes and put that as the key. Now, it's we're only showing this in a Now, it's we're only showing this in a Now, it's we're only showing this in a string right now. We're gonna put this string right now. We're gonna put this string right now. We're gonna put this into our options array in just a minute. into our options array in just a minute. into our options array in just a minute. Now, here's the tricky if statement. If Now, here's the tricky if statement. If Now, here's the tricky if statement. If I + one I + one I + one is less than args.length and I'll explain this in just a minute.

  18. and I'll explain this in just a minute. Args Args Args add um i + 1 add um i + 1 add um i + 1 starts with dash dash [snorts] [snorts] [snorts] oops dash oops dash oops dash equals false. equals false. equals false. Okay, so why are we doing this? Okay, Okay, so why are we doing this? Okay, Okay, so why are we doing this? Okay, first of all, what we're going to do is first of all, what we're going to do is first of all, what we're going to do is if the parameter starts with a dash if the parameter starts with a dash if the parameter starts with a dash dash, well then we know that's a key. dash, well then we know that's a key. dash, well then we know that's a key. And then we have to do is find the value And then we have to do is find the value And then we have to do is find the value for it. So we're going to look at the for it. So we're going to look at the for it. So we're going to look at the next parameter, the next arg that came next parameter, the next arg that came next parameter, the next arg that came through. So that's where i + one, we're through. So that's where i + one, we're through. So that's where i + one, we're checking to make sure that i + one isn't checking to make sure that i + one isn't checking to make sure that i + one isn't is still less than the length because if is still less than the length because if is still less than the length because if it's not less than the length, then that it's not less than the length, then that it's not less than the length, then that means we're out of bounds. There is no means we're out of bounds. There is no means we're out of bounds. There is no value for it. So as long as we're not value for it. So as long as we're not value for it. So as long as we're not out of bounds the next position, we're out of bounds the next position, we're out of bounds the next position, we're going to look at that next position and going to look at that next position and going to look at that next position and say, hey, does it start with the dash? say, hey, does it start with the dash? say, hey, does it start with the dash? Because if it does, it's another key.

  19. Because if it does, it's another key. Because if it does, it's another key. it's not a value because sometimes like it's not a value because sometimes like it's not a value because sometimes like our turbo option there is no value. It's our turbo option there is no value. It's our turbo option there is no value. It's just the key that's all. So we're making just the key that's all. So we're making just the key that's all. So we're making sure that the the next value does not sure that the the next value does not sure that the the next value does not start with a dash. And if it doesn't start with a dash. And if it doesn't start with a dash. And if it doesn't then we're going to do is say options then we're going to do is say options then we're going to do is say options key. So that's up here. We we figure out key. So that's up here. We we figure out key. So that's up here. We we figure out the key. Um so we're going to say hey the key. Um so we're going to say hey the key. Um so we're going to say hey the dictionary we're going to have the the dictionary we're going to have the the dictionary we're going to have the the key is the the key. um equals args the key is the the key. um equals args the key is the the key. um equals args at plus+ i. at plus+ i. at plus+ i. [snorts] Okay. Now, [snorts] Okay. Now, [snorts] Okay. Now, what does plus+ i do? Well, what it's what does plus+ i do? Well, what it's what does plus+ i do? Well, what it's going to do is add one to our increment. going to do is add one to our increment. going to do is add one to our increment. Now, we normally don't do this inside of Now, we normally don't do this inside of Now, we normally don't do this inside of the for loop, but here we're going to. the for loop, but here we're going to. the for loop, but here we're going to. But we're doing plus+ i, not i ++ But we're doing plus+ i, not i ++ But we're doing plus+ i, not i ++ because it's two different things. Okay. because it's two different things. Okay. because it's two different things. Okay. So what does I ++ versus I ++ I do?

  20. So what does I ++ versus I ++ I do? So what does I ++ versus I ++ I do? Well, the plus+ indicates when we're Well, the plus+ indicates when we're Well, the plus+ indicates when we're going to add to the value. In this case, going to add to the value. In this case, going to add to the value. In this case, we're going to add to the value of I and we're going to add to the value of I and we're going to add to the value of I and then use it as the parameter. then use it as the parameter. then use it as the parameter. Okay? But if we said I ++, we would be Okay? But if we said I ++, we would be Okay? But if we said I ++, we would be using I as the value and then adding to using I as the value and then adding to using I as the value and then adding to it. So we'd get the args at the same it. So we'd get the args at the same it. So we'd get the args at the same position we are now, which is not what position we are now, which is not what position we are now, which is not what we want. We want the args at the next we want. We want the args at the next we want. We want the args at the next position. position. position. So this is the equivalent of saying um I So this is the equivalent of saying um I So this is the equivalent of saying um I plus+ here and then using just I here. plus+ here and then using just I here. plus+ here and then using just I here. Okay, but this is where the the plus+ I Okay, but this is where the the plus+ I Okay, but this is where the the plus+ I and the I++ come in. If you worked with and the I++ come in. If you worked with and the I++ come in. If you worked with C or C++, these are, you know, or C or C++, these are, you know, or C or C++, these are, you know, or actually C++. Um, but these are, you actually C++. Um, but these are, you actually C++. Um, but these are, you know, common things to do is the the know, common things to do is the the know, common things to do is the the plus+ I and I++ and all the rest. Um, we plus+ I and I++ and all the rest. Um, we plus+ I and I++ and all the rest. Um, we wouldn't have to do this. We can do this wouldn't have to do this. We can do this wouldn't have to do this. We can do this in two lines if you want, but just note in two lines if you want, but just note in two lines if you want, but just note that's why we have to have plus+ i, not that's why we have to have plus+ i, not that's why we have to have plus+ i, not i ++. It just determines when we use i ++. It just determines when we use i ++. It just determines when we use when we calculate this value for the when we calculate this value for the when we calculate this value for the array. If it's plus+ is first, we do array. If it's plus+ is first, we do array. If it's plus+ is first, we do this. We do the addition first and then this. We do the addition first and then this. We do the addition first and then use it for the array position. If the use it for the array position. If the use it for the array position. If the plus+ is after then we use the i's value plus+ is after then we use the i's value plus+ is after then we use the i's value for the args and then we increment i.

  21. for the args and then we increment i. for the args and then we increment i. Okay. So if the next parameter next Okay. So if the next parameter next Okay. So if the next parameter next argument does not start with a dash that argument does not start with a dash that argument does not start with a dash that must be the value. Therefore we use that must be the value. Therefore we use that must be the value. Therefore we use that as the value for the key. Otherwise, we're going to say options we're going to say options at key at key at key equals null. Okay, we're not going to equals null. Okay, we're not going to equals null. Okay, we're not going to put a value. Remember, we have the the put a value. Remember, we have the the put a value. Remember, we have the the nullable string. So that the the value nullable string. So that the the value nullable string. So that the the value for that key is nothing. So if we pass for that key is nothing. So if we pass for that key is nothing. So if we pass in d-turbo in d-turbo in d-turbo with no parameter or no value for it, with no parameter or no value for it, with no parameter or no value for it, then we're just passing in a key of then we're just passing in a key of then we're just passing in a key of turbo and the value is is null. Okay, so turbo and the value is is null. Okay, so turbo and the value is is null. Okay, so now we can do that's a parser. Now, just now we can do that's a parser. Now, just now we can do that's a parser. Now, just so you know, this is kind of a preview so you know, this is kind of a preview so you know, this is kind of a preview uh because next week we're going to talk uh because next week we're going to talk uh because next week we're going to talk about a a a package that will make this about a a a package that will make this about a a a package that will make this a little easier and add new things to a little easier and add new things to a little easier and add new things to our command line parsing and make it our command line parsing and make it our command line parsing and make it simpler and a a help menu and all the simpler and a a help menu and all the simpler and a a help menu and all the rest. It's a lot that you don't need to rest. It's a lot that you don't need to rest. It's a lot that you don't need to do in every situation, which is why I'm do in every situation, which is why I'm do in every situation, which is why I'm teaching you just command line. Um but teaching you just command line. Um but teaching you just command line. Um but um there is a way to do some of this um there is a way to do some of this um there is a way to do some of this parsing because as you can see this parsing because as you can see this parsing because as you can see this parsing can get pretty complicated parsing can get pretty complicated parsing can get pretty complicated pretty quick and this is just a very pretty quick and this is just a very pretty quick and this is just a very very simple parser. There's ways to get very simple parser. There's ways to get very simple parser. There's ways to get around this or break this or you know if around this or break this or you know if around this or break this or you know if you have if you're using slashes instead you have if you're using slashes instead you have if you're using slashes instead of dashes and all the rest. Um we're

  22. of dashes and all the rest. Um we're of dashes and all the rest. Um we're going to not worry about that. We're going to not worry about that. We're going to not worry about that. We're going to say hey we control this and going to say hey we control this and going to say hey we control this and we're saying this is what you need to do we're saying this is what you need to do we're saying this is what you need to do for your app. Um, now notice that for your app. Um, now notice that for your app. Um, now notice that there's also nothing restricting people there's also nothing restricting people there's also nothing restricting people from passing different values in. So from passing different values in. So from passing different values in. So that's a whole another thing you have to that's a whole another thing you have to that's a whole another thing you have to deal with is, you know, if you're deal with is, you know, if you're deal with is, you know, if you're expecting d-name, but people pass in expecting d-name, but people pass in expecting d-name, but people pass in d-turbo, d-turbo, d-turbo, um, what are you going to do with that? um, what are you going to do with that? um, what are you going to do with that? Are you ignore it? Are you going to spit Are you ignore it? Are you going to spit Are you ignore it? Are you going to spit it back and say no? That's up to you. it back and say no? That's up to you. it back and say no? That's up to you. We're just getting the data into C, then We're just getting the data into C, then We're just getting the data into C, then you figure out how to handle it. Okay, you figure out how to handle it. Okay, you figure out how to handle it. Okay, but let's talk this data because right but let's talk this data because right but let's talk this data because right now the data is actually in a C# in a now the data is actually in a C# in a now the data is actually in a C# in a key value pair way. So let's do a for key value pair way. So let's do a for key value pair way. So let's do a for each each each we're going to say uh X in options. we're going to say uh X in options. we're going to say uh X in options. We're going to loop through that that We're going to loop through that that We're going to loop through that that options array. So now we have this this options array. So now we have this this options array. So now we have this this dictionary. We're loop through it. So dictionary. We're loop through it. So dictionary. We're loop through it. So we're going to say um let's just do we're going to say um let's just do we're going to say um let's just do let's make sure we handle the idea of let's make sure we handle the idea of let's make sure we handle the idea of Turbo not having a value. So I say if uh Turbo not having a value. So I say if uh Turbo not having a value. So I say if uh x do value is not null, x do value is not null, x do value is not null, then we're going to do a console right then we're going to do a console right then we're going to do a console right line string interpolation. Um line string interpolation. Um line string interpolation. Um and in here we're going to say xkey.

  23. and in here we're going to say xkey. and in here we're going to say xkey. Notice this is key and value because x Notice this is key and value because x Notice this is key and value because x is actually a key value pair. Um because is actually a key value pair. Um because is actually a key value pair. Um because every item in dictionary is two things every item in dictionary is two things every item in dictionary is two things key and a value. So we're looping key and a value. So we're looping key and a value. So we're looping through the dictionary. So x dokey and through the dictionary. So x dokey and through the dictionary. So x dokey and we'll say colon and x dot value. we'll say colon and x dot value. we'll say colon and x dot value. And then we're going to say else and And then we're going to say else and And then we're going to say else and this is if this is if this is if the x do value is null we'll just say the x do value is null we'll just say the x do value is null we'll just say console right line um and we'll say uh console right line um and we'll say uh console right line um and we'll say uh xkey. It's all print. Okay. Because xkey. It's all print. Okay. Because xkey. It's all print. Okay. Because there is no value for that one. Okay. So there is no value for that one. Okay. So there is no value for that one. Okay. So now we've got this parser in place. now we've got this parser in place. now we've got this parser in place. Let's run this. Let's run this. Let's run this. And now we can see hello the value is And now we can see hello the value is And now we can see hello the value is world turbo is on its own and then test world turbo is on its own and then test world turbo is on its own and then test and this is a test. Now we could do is and this is a test. Now we could do is and this is a test. Now we could do is do some work where we could say um you do some work where we could say um you do some work where we could say um you know know know if um if um if um uh let's go with options and say options uh let's go with options and say options uh let's go with options and say options and then the key would be hello is not null is not null then then then Um hello and I can say actually let's do a hello and I can say actually let's do a string interpolation here

  24. and then say options and then say options at position at position at position hello [snorts] [snorts] like so. And yes, this is getting messy like so. And yes, this is getting messy like so. And yes, this is getting messy because I didn't um close the curly because I didn't um close the curly because I didn't um close the curly braces out. braces out. braces out. There we go. So it's going to say hello There we go. So it's going to say hello There we go. So it's going to say hello world hopefully. world hopefully. world hopefully. Yep. Hello world right there. Boom. So Yep. Hello world right there. Boom. So Yep. Hello world right there. Boom. So you can start pulling out and using you can start pulling out and using you can start pulling out and using these values and saying hey if it's not these values and saying hey if it's not these values and saying hey if it's not if the key is there then do this um if if the key is there then do this um if if the key is there then do this um if the key is there for um I don't know we the key is there for um I don't know we the key is there for um I don't know we could change it to test and say if the could change it to test and say if the could change it to test and say if the key is there then um key is there then um key is there then um oh I the key is there for test. We have oh I the key is there for test. We have oh I the key is there for test. We have to say you know test there too. um hello to say you know test there too. um hello to say you know test there too. um hello this is a test right so you can pull in this is a test right so you can pull in this is a test right so you can pull in different values um based upon different different values um based upon different different values um based upon different keys of course that doesn't make a whole keys of course that doesn't make a whole keys of course that doesn't make a whole lot of sense but sure you know you can lot of sense but sure you know you can lot of sense but sure you know you can grab those so you can say things like grab those so you can say things like grab those so you can say things like hey if if there's a name supplied or hey if if there's a name supplied or hey if if there's a name supplied or maybe more appropriately hey is there a maybe more appropriately hey is there a maybe more appropriately hey is there a file name associated like if you pass in file name associated like if you pass in file name associated like if you pass in a file path then you can process that a file path then you can process that a file path then you can process that file um I do this for my um simple image file um I do this for my um simple image file um I do this for my um simple image viewer where I pass in a a command line viewer where I pass in a a command line viewer where I pass in a a command line argument that says Hey, are you looking argument that says Hey, are you looking argument that says Hey, are you looking for if you're in a current directory, for if you're in a current directory, for if you're in a current directory, grab all the files in that directory.

  25. grab all the files in that directory. grab all the files in that directory. And so it's a command line argument that And so it's a command line argument that And so it's a command line argument that that pulls it in. It finds all the that pulls it in. It finds all the that pulls it in. It finds all the images from the directory and then shows images from the directory and then shows images from the directory and then shows them in my display viewer. So them in my display viewer. So them in my display viewer. So command line arguments can really command line arguments can really command line arguments can really valuable and they can allow you to have valuable and they can allow you to have valuable and they can allow you to have your app respond to different set of your app respond to different set of your app respond to different set of circumstances at startup. You can say, circumstances at startup. You can say, circumstances at startup. You can say, hey, you know, what is the uh network hey, you know, what is the uh network hey, you know, what is the uh network address of this computer? or hey what is address of this computer? or hey what is address of this computer? or hey what is you know and pass in data and have your you know and pass in data and have your you know and pass in data and have your app then work on that data as part of app then work on that data as part of app then work on that data as part of its startup options. So really helpful its startup options. So really helpful its startup options. So really helpful but not a lot of people know how to but not a lot of people know how to but not a lot of people know how to parse and work with them. Um this tool parse and work with them. Um this tool parse and work with them. Um this tool allows you to make them the parsing a allows you to make them the parsing a allows you to make them the parsing a little easier and kind of shows you how little easier and kind of shows you how little easier and kind of shows you how to pull those arguments out in other to pull those arguments out in other to pull those arguments out in other places as well. Notice the parser would places as well. Notice the parser would places as well. Notice the parser would still work the same way in here if we still work the same way in here if we still work the same way in here if we wanted to implement it here. Um, but wanted to implement it here. Um, but wanted to implement it here. Um, but that's how command line arguments work that's how command line arguments work that's how command line arguments work in C um, int applications. So, I in C um, int applications. So, I in C um, int applications. So, I encourage you to check them out. Make encourage you to check them out. Make encourage you to check them out. Make sure you understand them at least. It's sure you understand them at least. It's sure you understand them at least. It's another tool in your toolbox for when another tool in your toolbox for when another tool in your toolbox for when it's it's valuable. And C# apps in it's it's valuable. And C# apps in it's it's valuable. And C# apps in general all take command line arguments.

  26. general all take command line arguments. general all take command line arguments. Yes, even web apps take command line Yes, even web apps take command line Yes, even web apps take command line arguments. It's just that the web app it arguments. It's just that the web app it arguments. It's just that the web app it takes a command line argument when it takes a command line argument when it takes a command line argument when it starts the web app which is not usually starts the web app which is not usually starts the web app which is not usually something you do very often but it can something you do very often but it can something you do very often but it can be valuable because you can say things be valuable because you can say things be valuable because you can say things like hey you're on this server or hey like hey you're on this server or hey like hey you're on this server or hey you're going to connect to this cluster you're going to connect to this cluster you're going to connect to this cluster or hey you know whatever the case may be or hey you know whatever the case may be or hey you know whatever the case may be for when you're starting up and start up for when you're starting up and start up for when you're starting up and start up different um you know the same web app different um you know the same web app different um you know the same web app but on different servers with different but on different servers with different but on different servers with different parameters at startup. So that can be parameters at startup. So that can be parameters at startup. So that can be very helpful in that case. Um, but you very helpful in that case. Um, but you very helpful in that case. Um, but you can pull this in different apps. I I may can pull this in different apps. I I may can pull this in different apps. I I may do a video ask, you know, leave a do a video ask, you know, leave a do a video ask, you know, leave a comment down below if they see a video comment down below if they see a video comment down below if they see a video on how to do this with like Windforms on how to do this with like Windforms on how to do this with like Windforms WPF where there's not really a uh clear WPF where there's not really a uh clear WPF where there's not really a uh clear way to do this. But really what it comes way to do this. But really what it comes way to do this. But really what it comes down to is just use this in most cases, down to is just use this in most cases, down to is just use this in most cases, but there are times when you would want but there are times when you would want but there are times when you would want to switch over to using a program.cs to switch over to using a program.cs to switch over to using a program.cs type startup for WPF or Windforms. Um, type startup for WPF or Windforms. Um, type startup for WPF or Windforms. Um, and there are ways of doing that. Um, so and there are ways of doing that. Um, so and there are ways of doing that. Um, so just note that you can do that if you just note that you can do that if you just note that you can do that if you want. Um, because you might want to want. Um, because you might want to want. Um, because you might want to start the app with those parameters, not start the app with those parameters, not start the app with those parameters, not wait until a form loads to grab them.

  27. wait until a form loads to grab them. wait until a form loads to grab them. Okay, so anyways, let me know if your Okay, so anyways, let me know if your Okay, so anyways, let me know if your your thoughts down in the comments. your thoughts down in the comments. your thoughts down in the comments. Thanks for watching. Again, next week Thanks for watching. Again, next week Thanks for watching. Again, next week we'll um we'll cover the way to parse we'll um we'll cover the way to parse we'll um we'll cover the way to parse this even easier and do some more cool this even easier and do some more cool this even easier and do some more cool stuff with command line arguments. stuff with command line arguments. stuff with command line arguments. Thanks for watching. As always, I am Tim Thanks for watching. As always, I am Tim Thanks for watching. As always, I am Tim Corey. [music]

No summary available yet.

View original episode ↗