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...

ความคิดเห็น • 27

  • @p199a
    @p199a 8 หลายเดือนก่อน +3

    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.

    • @IAmTimCorey
      @IAmTimCorey  8 หลายเดือนก่อน +4

      Going forward, it will be, yes. You should know how to do both, but use the modern way going forward.

    • @BittermanAndy
      @BittermanAndy 8 หลายเดือนก่อน +2

      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.

  • @christianimfeld7357
    @christianimfeld7357 หลายเดือนก่อน

    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

  • @tetley3737
    @tetley3737 8 หลายเดือนก่อน +1

    Command Line Arguments can also be added in the project's properties.

  • @connormccarter9581
    @connormccarter9581 8 หลายเดือนก่อน

    This is awesome! Now I can update my console app to winform and retain the right click functionality.

    • @IAmTimCorey
      @IAmTimCorey  8 หลายเดือนก่อน

      Great!

    • @phillismable6303
      @phillismable6303 8 หลายเดือนก่อน

      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.

  • @X400DYL
    @X400DYL 8 หลายเดือนก่อน

    Tim, Quick question, what Extension are you using for the different coloured Braces ? Thanks

    • @IAmTimCorey
      @IAmTimCorey  8 หลายเดือนก่อน +1

      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

    • @X400DYL
      @X400DYL 8 หลายเดือนก่อน +1

      Spot on thanks :)@@IAmTimCorey

  • @dreddy5187
    @dreddy5187 6 หลายเดือนก่อน

    Is this only in .net 8 or can you use command line args in winforms with .net framework 4.8?

    • @IAmTimCorey
      @IAmTimCorey  6 หลายเดือนก่อน +1

      You can use command line arguments with .NET Framework as well.

  • @gower1973
    @gower1973 8 หลายเดือนก่อน

    Why do you have to do this ./ infront of the executable?

    • @IAmTimCorey
      @IAmTimCorey  8 หลายเดือนก่อน

      I was using PowerShell, which requires an included path.

  • @AvgDan
    @AvgDan 6 หลายเดือนก่อน

    MS should have made the template include a code comment with something like "// Current scope is Main(string[] args)" when using top level statements.

    • @IAmTimCorey
      @IAmTimCorey  6 หลายเดือนก่อน +1

      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.

    • @AvgDan
      @AvgDan 6 หลายเดือนก่อน

      ​@@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.

  • @E_G_
    @E_G_ 8 หลายเดือนก่อน

    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?

    • @Lukas-gx9qk
      @Lukas-gx9qk 8 หลายเดือนก่อน +1

      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

    • @IAmTimCorey
      @IAmTimCorey  8 หลายเดือนก่อน

      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