Command Line Arguments in C# Applications in 10 Minutes or Less
ฝัง
- เผยแพร่เมื่อ 11 ก.ย. 2024
- Sometimes, you want to launch your application with parameters that might change. For instance, when we launch docker, we tell it what image to load or what task to perform. C# applications can operate the same way.
In this 10-minute training episode, we will see how to accept command-line arguments in Console applications, including how to read multi-part arguments. We will also look at how to modify a WinForm application to take command-line arguments.
Full Training Courses: IAmTimCorey.com
Source Code: leadmagnets.ap...
Mailing List: signup.iamtimc...
Hey Tim I am doing your C# Mastercourse and I notice u are using top-level statements. Is it industry standard now?? Or you doing it because its less confusing for new ppl? I personally likes that each file looked the same and now main file feels weird.
Going forward, it will be, yes. You should know how to do both, but use the modern way going forward.
Feel free to ignore "the modern way". I agree that it looks worse, I won't be using it and neither will the teams I work with. Do whatever you prefer.
Hi Tim, thanks for the great "short" video. Is there a good open source library which you could recommend to use to parse/handle the command line options; I would like to avoid implementing this. Regards Christian
Command Line Arguments can also be added in the project's properties.
Yep.
This is awesome! Now I can update my console app to winform and retain the right click functionality.
Great!
The C programming Language
By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice-Hall in 1988
ISBN 0-13-110362-8 (paperback) ISBN 0-13-110370-9
This is where I learned both C and CLI from and I’ve never forgotten it, it was the bible before the internet blew up and we still had DOS.
Tim, Quick question, what Extension are you using for the different coloured Braces ? Thanks
It is built into Visual Studio. Here is a video on how to enable it: th-cam.com/video/O1GUbjacjKQ/w-d-xo.htmlsi=rzQzhflQ7PkmPiwb
Spot on thanks :)@@IAmTimCorey
Is this only in .net 8 or can you use command line args in winforms with .net framework 4.8?
You can use command line arguments with .NET Framework as well.
Why do you have to do this ./ infront of the executable?
I was using PowerShell, which requires an included path.
MS should have made the template include a code comment with something like "// Current scope is Main(string[] args)" when using top level statements.
They linked to the documentation that explains that. Trying to put just that in a code comment would be incomplete, because it doesn't also cover return types, async, etc.
@@IAmTimCoreyI could see how it could use more explanation, but I'd hate to be just starting out, not having prior experience before it was taken away.
Hello Tim, I have a question to ask :) I have subscribed to your tutorials but there are different videos in your TH-cam channel. Before starting tutorials, I am a little bit confused. Do you have suggestions?
I suspect you mean you subscribed to the channel @IAmTimCorey
You can look through all these playlists, or just through the videos and find topics that interest you:
www.youtube.com/@IAmTimCorey/playlists
I'm sorry, I don't understand your question. Are you asking what order to watch my videos in? If so, I don't have one because my content isn't linear like that. However, the Path to C# in 2024 video should help you figure out what order to learn C# in: th-cam.com/video/YErrKU1dq0g/w-d-xo.htmlsi=NgyuEfNipL6O8ec1