Intro to Console Apps in C# in .NET 6

Sdílet
Vložit
  • čas přidán 2. 08. 2024
  • The Console application type is often overlooked, but it can be one of the most powerful project types in C#. In fact, if you are learning C#, this should be the first project type that you learn, and it should be one you stick with for your first fifty projects. In this video, we are going to look at what the console project type is, how to get started with it, and then when you would use this project type.
    C# Projects Site: www.csharpprojects.com
    Suggestions: suggestions.iamtimcorey.com
    Full Training Courses: IAmTimCorey.com
    Source Code: leadmagnets.app/?Resource=Int...
    Mailing List: signup.iamtimcorey.com/
    0:00 - Introduction "Console Application Type"
    1:08 - Visual Studio demo, create and run a simple .net 6 console application
    3:50 - New "Top level statements" in .NET 6
    5:00 - Console window
    5:35 - Console class
    11:16 - Why Console app and when to use it.
    12:00 - Easy to learn C# using console applications
    15:42 - Quick applications (To implement something quickly)
    16:30 - Automation
    23:51 - Summary
    26:41 - Discover C# project types

Komentáře • 85

  • @danielwilliams483
    @danielwilliams483 Před 10 měsíci +3

    Most apps I write a console apps at heart. And they may just run pure console, or may become a service, or a web host. But always console at heart.

  • @johng5295
    @johng5295 Před rokem

    Thanks in a million my brother again, Tim! Great content. Awesome. Very well explained. I couldn't find this content--simply put anywhere else. Grade: A++ 💥

  • @Norman_Fleming
    @Norman_Fleming Před rokem +1

    Thank you for continuing to evangelize for the console application. So much power that is lost when a developer starts out at a higher level without knowing the foundations it all sits upon.
    Supporting redirection from one into the next so you can create data flows from a command line. #nix variants thrive on the concept.

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      You are welcome. It is an amazing project type, for sure.

  • @michaelschneider603
    @michaelschneider603 Před rokem

    Programmed in BASIC on the C64, Pascal on the Apple II, and assembly language on the Amiga console during the 80s, Lisp under MSDOS and C / C++ in the Linux console during the 90s, then Java console-only for almost 20 years, and programming in Python is console-first anyways. Did I ever do any non-console programming in C# yet? Now that I'm thinking about it, with your hint that web apps are technically console apps, actually no! Video was fun to watch, even if I wasn't the intended audience. :-)

  • @Skillamu
    @Skillamu Před rokem

    Great video! Thanks!

  • @sakhawathussain9696
    @sakhawathussain9696 Před rokem

    Thanks for your convey .

  • @andywalter7426
    @andywalter7426 Před rokem

    One great use case I found for console is a process I created where I have a custom nuget system where I have a text file that lists projects I want to use my custom system with. When I run the console app, it scans all of them and if there are any detected changes, then it creates a nuget package and even uploads to public nuget as well.

  • @chinedumgbedoro5362
    @chinedumgbedoro5362 Před 2 měsíci

    thank you very much, Tim, great content

  • @rafaelm.2056
    @rafaelm.2056 Před rokem +2

    Do you have any videos that describe how to implement interfaces, abstract classes, and references to other classes or projects like we use to be able to do before top level was introduced? Or do I need to rebuild my own namespaces and class declarations from scratch and carry on from there?

  • @mandeath2971
    @mandeath2971 Před rokem

    Thanks for the Effort

  • @tituschristopher5568
    @tituschristopher5568 Před rokem

    Wonderful

  • @getimad1076
    @getimad1076 Před rokem +2

    Awesome video 👍
    We love console applications 💜
    Can you please make course about MSTEST and Live Unit Testing
    Thank you 😊

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

  • @zarokoshin4090
    @zarokoshin4090 Před rokem +1

    Nice vid. ! There will be a newer WPF vid with native builder settings and mvvm ? :)

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

  • @programmingmadeclear
    @programmingmadeclear Před rokem

    Nice video, try Alt arrow up or down to move a line up or down without cut and paste. Best regards 👍🏼👍🏼

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Yeah, I forget to do that since I don't do it that often.

  • @danielwilliams483
    @danielwilliams483 Před 10 měsíci

    Is there a good way to set the location of the console window? Is there a cross-platform way to do it in net core? Just would like it to consistently be in a certain location, rather than on top of Visual Studio.

  • @lokinc.3735
    @lokinc.3735 Před rokem

    I have a Console app that uses DirectoryServices to validate login and then it connects to a database to manage assets. I'm used to using HttpS with Web. How does a Console app transmit data and does it need some form of secure connection to protect data in transfer from something like wireshark?

  • @Dazza_Doo
    @Dazza_Doo Před rokem +1

    Yes the Stigma with the console app is that it was for beginners only or marauders

  • @michaelday6987
    @michaelday6987 Před rokem +1

    If you work in the world of Insurance, Banking, Finance, etc. you will find yourself working on console apps. Especially as a junior developer. Overnight, Weekly or Monthly processing are quite often done through a console application. You will need to know how to create, use and update real world console apps. They are not just for learning. You need to understand the difference between a tutorial application and a production application.

  • @EugeneSkakun
    @EugeneSkakun Před rokem

    nice

  • @joeprincipato5211
    @joeprincipato5211 Před rokem +1

    if you are using Console apps for learning purposes, are there any drawbacks on having multiple consoles projects in a solution?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Nope. I have one solution that has 18 console apps in it.

    • @joeprincipato5211
      @joeprincipato5211 Před rokem

      @@IAmTimCorey thanks, I just wanted to be sure before I tried it...

  • @rachanareddy6615
    @rachanareddy6615 Před rokem

    @IamTimCorey
    1. how do we get .exe file
    2. What is difference between debug mode and release mode

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      The exe file is created when you build the project. It is in the bin folder under your project (a couple layers in). The difference between debug and release mode is that in debug mode, Visual Studio make debugging easier. For example, it holds onto variable values after they are no longer needed so that you can see them in a breakpoint even though normally they would have been destroyed. Release mode makes the code as efficient as possible.

  •  Před rokem

    May be I'm too old, but the best for learning "command line" is try to learn more about any unix like os (any linux, gnu, ....) this is working decades and lat few years Windows ecosystem reinvent the wheel :-) all small utilities in linux like sed, grep, ....... are ment to do one thing good so you can pipe more utilities and do a lot. I'm still impresed how smart is unix/linux about utilities and how easily you can use them. When Microsoft realize that clicking with mouse and windows registry is not the right way of doing things they "invented" powershell. But the beauty of Linux/Unix systems is in the long lived principles which are adopted in Windows world after a lot of blind ways of doing things.

  • @andywalter7426
    @andywalter7426 Před rokem

    I thought the most common way of doing automation is web apis and class libraries? What are cases where console is best for automation instead of class libraries and web apis? I've done lots of automation stuff with class libraries especially.

    • @David-rz4vc
      @David-rz4vc Před rokem +3

      I used console app everytime for integration between vendors. For example, pulling data from a database to push to the vendor. But since I need to run this nightly or twice a day I can take this console app and run it in windows task scheduler at any configured interval.

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      An API typically needs a caller to do work. Some automation tasks do not fit in that category. For instance, a scheduled service such as sending daily emails, building reports, backups, etc. These are all better off as a console application. Also, a console app does not require a web server to run. You can set up services and other automations on your machine that are for just your machine. You wouldn't want the overhead of a web server running for local work.

    • @andywalter7426
      @andywalter7426 Před rokem

      @@IAmTimCorey Wouldn't it be best sometimes to have a wpf app that calls the automation functions? Because on one job, I actually had a wpf app that called class libraries and reported the progress to a text box. I found that for some automated processes, its best to just call the wpf app and then see the progress. I tried console but would not show the progress when something needs to run all the time. I had windows services actually run the wpf app so if I want to know what the status of the processes running, i just run remote desktop and see the progresses.

    • @rachanareddy6615
      @rachanareddy6615 Před rokem

      @@IAmTimCorey even the console job needs to be called somewhere right ro execute??

  • @maryambibi9687
    @maryambibi9687 Před rokem

    do some projects on console application

  • @gloryforever8399
    @gloryforever8399 Před rokem

    Do you have a C# course using .net 6 from beginners to advanced?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      The C# Mastercourse ( www.iamtimcorey.com/courses/csharpmastercourse.html ) covers .NET 6 well, although it doesn't ONLY cover .NET 6 since it is important to know .NET from the .NET Framework through .NET 6 in the real world. I point out when things are different from one version to another.

  • @jdang67
    @jdang67 Před rokem +1

    How do we add a new function in the ConsoleApp?

    • @guliveryorran
      @guliveryorran Před rokem

      I'm trying to discovery too, do you know the answer?

  • @psinka1292
    @psinka1292 Před rokem

    i love you

  • @delw1138
    @delw1138 Před rokem

    I use console apps to email custom reports from servers, automate some maintenance, etc...

  • @andywalter7426
    @andywalter7426 Před rokem

    One question is can console apps run on android devices like phones and tablets? Would be nice if it could.

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Nope, desktops and the cloud.

    • @micro2743
      @micro2743 Před rokem

      @@IAmTimCorey A .net 5 or later console app can also run on Linux and Mac, but not mobile.

  • @xavikun3009
    @xavikun3009 Před rokem

    sir please i wanna know where did u get microsoft vs debug console

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      I'm not sure what you mean. I'm using a standard version of Visual Studio (2022 Community Edition). If you mean the Debug or Output windows in Visual Studio, you can find them under the View menu.

    • @bryanhobson1822
      @bryanhobson1822 Před rokem

      @@IAmTimCorey I think @xavi kun is referring to the console window in which you run the application. If you look closely at the window when your application has finished running, the title bar changes to "Microsoft Visual Studio Debug Console", as per Xavi's question.
      When you build and run you application Xavi, this window is simply the console window that you see your application running in.

  • @yperman1
    @yperman1 Před rokem

    Before even watch it Like and Thanks !

  • @Mo_TEK
    @Mo_TEK Před rokem

    waiting WINUI3 video with sqlite database ???? sooon?????

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/

    • @micro2743
      @micro2743 Před rokem

      WinUI 3 is already on the suggestion list.

  • @mistywhisp
    @mistywhisp Před rokem

    lol i installed cisual studio code instead of visual studio 2022 so that's what I'm downloading right now lol

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      Bummer. That will be a big install.

    • @mistywhisp
      @mistywhisp Před rokem

      @IAmTimCorey I installed it and made a game w the help of your tutorial and some guides online basically you pick some food and each piece of food is worth so many points then your score is the combined total.

  • @jamiewalker6296
    @jamiewalker6296 Před rokem

    Maybe its because i am newer in c#, but i do not like top level statements. I do not like them Sam I am.

  • @gower1973
    @gower1973 Před rokem

    If the .net framework version of console app is the old one and deprecated why don’t they say that on the damn template! As a beginner how am I supposed to know the difference?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +1

      It isn't deprecated. It is still fully supported and will be for as long as Windows is supported. It is the older framework and no new work is being done on it, but it has not been deprecated.

    • @Dazza_Doo
      @Dazza_Doo Před rokem +1

      Watch more videos, Tim has many about this subject. .Net6 and C#10 are the currently implantations, later this year they will release a new version.

  • @buddysteve5543
    @buddysteve5543 Před rokem

    This man would have had $50/mo from me if he were offering it but guess he doesn't want my monthly subscription! Weird! Oh well, plenty of other people who'll take my monthly subscription!

    • @IAmTimCorey
      @IAmTimCorey  Před rokem

      It isn't that I don't want to offer the monthly subscription all the time. It is that I can't really, without opening up myself to theft and abuse of the offer.

  • @Dazza_Doo
    @Dazza_Doo Před rokem

    Useful Console Commands
    Change Text Colour: *Console.ForegroundColor = ConsoleColor.DarkGreen;* You will get a popup list if you remove .DarkGreen
    Change Console *Title: Console.Title = "My Cool APP ";*
    Get Number/Float/Decimal Input Without Breaking Your Program: Step 1: *var _result = Console.ReadLine();* Saves this in temporary _result for step 2
    Step 2: *_bool = int.TryParse(_result, out Value);*
    Value is your result if it works, You can check the _bool and it will give you true : false