How to Program C# in Visual Studio Code [2023]

Поділитися
Вставка
  • Опубліковано 19 чер 2024
  • Developing C# in Visual Studio Code is simple, doesn't cost anything, and offers a great cross-platform developer experience.
    00:00 Introduction
    00:21 Installing the C# Dev Kit
    00:56 Creating a Console App
    03:40 Creating a Blazor Server App
    04:39 Conclusion
    🔥 C#/.NET Bootcamp: The Fundamentals & more (Code FRIENDS10 for 10% OFF)*
    claudiobernasconi.ch/dotnet-c...
    📌 .NET Developer Roadmap
    claudiobernasconi.ch/learn-do...
    📌 UA-cam Playlists:
    Infrastructure as Code: • Infrastructure as Code
    The FREE Blazor Crash Course: • The FREE Blazor Crash ...
    C# Programming: • How to Create Modern C...
    ✅ SUBSCRIBE FOR MORE VIDEOS
    Subscribe: 🔔 claudiobernasconi.ch/Subscribe
    🚀 CONNECT & SUPPORT
    Twitter: / chbernasconic
    Blog: claudiobernasconi.ch
    Newsletter: claudiobernasconi.ch/newsletter
    CREDITS
    🎵 www.bensound.com/
    * Affiliate Link: I earn a small commission at no additional cost
  • Наука та технологія

КОМЕНТАРІ • 55

  • @ClaudioBernasconi
    @ClaudioBernasconi  11 місяців тому +4

    What is your preferred way of programming C#? How do you like the C# Dev Kit extension? 😎

  • @charlesssgraham
    @charlesssgraham 9 місяців тому +2

    I took your ZTM C# course and loved it! I didn't know you had a UA-cam channel, it's so awesome to discover you're also a content creator. Instant sub!

    • @ClaudioBernasconi
      @ClaudioBernasconi  9 місяців тому

      That's so kind of you. Thank you so much. Welcome! 🙂

  • @gold_friday
    @gold_friday 4 місяці тому

    Thank you.. It works for me!!

  • @Nasengold
    @Nasengold 4 місяці тому +7

    It is ridiculous how complicated c# is compared to python. In python I can just go and run and test everything within seconds.

    • @ClaudioBernasconi
      @ClaudioBernasconi  4 місяці тому

      I think those languages have different targets, and depending on what type of application you want to build, C# or Python might be preferable. In case you understand both languages, you have such a wide range of opportunities. Glad to see you on my channel.

  • @raushanpandey6053
    @raushanpandey6053 3 місяці тому

    Thank you brother!

  • @usamaradwan
    @usamaradwan 27 днів тому

    Thank you so much!
    It's a great tutorial!

  • @fredimachadonet
    @fredimachadonet 11 місяців тому +1

    As far as I know the C# Dev Kit extension has a license similar to VS 2022 Community. Free for individual developers or small companies. Thanks for the content!

    • @ClaudioBernasconi
      @ClaudioBernasconi  11 місяців тому +2

      Thanks for mentioning it; good point. I do believe that most developers who want to use Visual Studio Code for C# development qualify for the free license. If there are companies with $1M+ revenue per year, I assume they are happy to pay for tooling that helps them make their money. In that case, you can discuss using Rider or full VS instead, but that choice is up to them.

  • @SrimathiJayaraman
    @SrimathiJayaraman Місяць тому

    This was really helpful at the right time!

    • @ClaudioBernasconi
      @ClaudioBernasconi  Місяць тому

      Thanks for your feedback. I'm glad the video helped you out!

  • @panda986
    @panda986 4 місяці тому

    I don't have the Index.razor when making the BlazorApp1. Do you know why is that?
    The icons next to them are also just the common lines. (same as .sln file) + i didn't get _Host.cshtml file
    Do I need to install or add an extension for them to show?

    • @ClaudioBernasconi
      @ClaudioBernasconi  4 місяці тому +1

      This video was recorded using .NET 7. The new Blazor App Project template that came with .NET 8 is slightly different. I recorded a video about the changes that will help you out: ua-cam.com/video/DO9TO9EreOs/v-deo.html

    • @panda986
      @panda986 4 місяці тому

      @@ClaudioBernasconi thank you

  • @WetPrime
    @WetPrime 5 місяців тому

    Hello!
    After 10 videos and still not getting my vscode to work your video helped me out great!
    Thanks for an awsome video man! I just have one question, when you are typeing in the console at 4:05 you are getting the .\Blazorapp1\ there in like 1 tap, how do you do that ?
    Have a nice day! cheers

    • @ClaudioBernasconi
      @ClaudioBernasconi  5 місяців тому

      Thank you so much, I'm happy you could finally find a way that works for you. 👏 I either cut the video, but most likely used the TAB key to autocomplete the path. You can hit the key multiple times to get the next entry in alphabetical order. I hope this helps.

  • @guillermomazzari8320
    @guillermomazzari8320 11 місяців тому

    Hi, I tried to make a web api project, but it created a minimal API project, would you know why? Is this something they will change in the future? as well as being able to choose the framework net6 or 7, for example

    • @ClaudioBernasconi
      @ClaudioBernasconi  11 місяців тому +1

      Great question. It seems like the currently supported project types do not offer an option to create a WebAPI project that contains controllers instead of using Minimal APIs. You can raise an issue on their GitHub to gather their feedback. github.com/microsoft/vscode-dotnettools

    • @guillermomazzari8320
      @guillermomazzari8320 11 місяців тому

      @@ClaudioBernasconi Thanks for sharing, and answering!! Ill do as you suggest!!

  • @trongtue8384
    @trongtue8384 5 місяців тому

    Hi! I want to asked that why when i using commend line in VSC: ""dotnet new console --framework net8.0 --use-program-main" to run a console application, I get these code by default:
    namespace OOP;
    class Program
    {
    static void Main(string[] args)
    {
    Console.WriteLine("Hello, World!");
    }
    }
    Instead of these code in VS:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    namespace OOP
    {
    public class Program
    {
    static void Main(string[] args)
    {
    Console.WriteLine("Hello, World!");
    }
    }
    }
    SO I don't know which code is right ? And how to create a console application project in VSC with the default code like in VS. Thank you

    • @ClaudioBernasconi
      @ClaudioBernasconi  5 місяців тому +2

      The first version uses file-scoped namespaces and implicit usings both introduced in C# 10. It's the more modern approach to implementing the Program class for any C# application. There is an even shorter version using top-level statements where the Program class is hidden from the developer. Both are correct and work. You should be able to verify that by running the compiler and starting the application.
      Those are basics and I highly recommend learning them if you want to understand C# and the .NET platform. I have a compact and affordable Bootcamp course on Zero to Mastery. You find a link below all recent videos on the channel.

    • @trongtue8384
      @trongtue8384 5 місяців тому

      @@ClaudioBernasconi Thank you for your answer. I have more one question is that: does coding C# in VSC have any disadvantage compare to VS or not ? Because I afraid C# in VSC don't have many support or feature compare to VS. Thank you

  • @Anonymous-qb4ys
    @Anonymous-qb4ys 4 місяці тому

    Is there any way to automatically compile/run when you press the run button?

    • @ClaudioBernasconi
      @ClaudioBernasconi  4 місяці тому +1

      Great question! I'm sure you can configure that. I haven't tried it myself, though.

    • @Anonymous-qb4ys
      @Anonymous-qb4ys 4 місяці тому

      @@ClaudioBernasconi I didn't find anything about it on the internet and no extension. Mine gives the error 'unable to find the project that contains... Program.cs'. Some way of connecting this button to the dotnet run command would be enough, it doesn't seem like something very difficult, but I've never seen anyone doing it

  • @programedegraca
    @programedegraca 8 місяців тому +1

    Que conteúdo excelente. Muito obrigado.

  • @chomulol3287
    @chomulol3287 11 місяців тому

    I cannot create a dot net terminal it says that it is not recognised as the name of a cmdlet function help

    • @ClaudioBernasconi
      @ClaudioBernasconi  11 місяців тому

      You need to install the .NET SDK and make sure it is added to the PATH variable. Also, restart your terminal ir your computer after the instsllation. There are many videos that show how to do it.

    • @chomulol3287
      @chomulol3287 11 місяців тому

      @@ClaudioBernasconi what should I search to see those videos brother?

    • @chomulol3287
      @chomulol3287 11 місяців тому

      @@ClaudioBernasconi I have .net SDK 7how to make sure it's added to the path variable and I can't find the c# extension that you downloaded

  • @DhruvGoel-jc1lp
    @DhruvGoel-jc1lp Місяць тому

    Amazing

  • @razakalsharafy4708
    @razakalsharafy4708 5 місяців тому

    شكرا جزيلا

  • @wahyukanaeru3138
    @wahyukanaeru3138 5 місяців тому

    Well

  • @phantomforcesguy
    @phantomforcesguy 3 місяці тому

    everytime i select net project the console app dosen't appear

    • @phantomforcesguy
      @phantomforcesguy 3 місяці тому

      small little update i managed to kind of debug it by using json but it said git extension not found

    • @ClaudioBernasconi
      @ClaudioBernasconi  3 місяці тому +1

      Unfortunately, I cannot help you with your issues. Maybe record a video and post it online with a well documented step-by-step guide? Maybe Stackoverflow?

    • @phantomforcesguy
      @phantomforcesguy 3 місяці тому

      @@ClaudioBernasconi don't worry i did it just had to log in to my microsoft account connect it blah blah blah i hate how much stuff you have to do to make a hello world script

  • @pilotboba
    @pilotboba 11 місяців тому +1

    Visual Studio community is free (but yes, windows only)

    • @ClaudioBernasconi
      @ClaudioBernasconi  11 місяців тому

      Yes, and I heard of many developers who prefer a lightweight IDE/Editor. Many JavaScript or TypeScript developers explore C# like the platform or the language but do not want to use Visual Studio. I think the solution presented here provides a great developer experience in Visual Studio Code.

    • @pilotboba
      @pilotboba 11 місяців тому +1

      @@ClaudioBernasconi I'm not disputing tjat at all. Just pointing out something some people may not realize. If you can't afford it, your possibly in the group that can use the community edition legally.
      But, yes the C# DevKit looks great, and I hope they continue to improve it.
      Also, nothing beats devcontainers and remote development which afaik you still can't use with Visual Studio.

  • @verdaisilplayz
    @verdaisilplayz 6 місяців тому

    Vs Community is free (i using community im poor lol)

    • @ClaudioBernasconi
      @ClaudioBernasconi  6 місяців тому

      VS Community is free for personal and educational use and for open-source development. For commercial usage, you need a license if your company makes more than $1M in revenue per year. Please read more about the licensing of Visual Studio on Microsoft's website. This is no legal advice.

  • @ottomaier7127
    @ottomaier7127 11 місяців тому

    Yes, it's cross plattform (I hope that this is true, I didn't try it yet). But anyway, I don't like it. The editor and especially it's setting dialogs are a nightmare. Since I have VS (not VSCode), and if not, i could have it for free (Community Edition), I don't understand this VSCode hype at all.
    IMO, there's no need for VSCode other than cross platform.

    • @ClaudioBernasconi
      @ClaudioBernasconi  11 місяців тому +1

      Thanks for your comment. I think Visual Studio is the best option when running on Windows. I use it myself the most. However, when you have a Mac or use Linux, you cannot use Visual Studio. Therefore, I believe the setup shown here is valuable to that audience.

    • @ottomaier7127
      @ottomaier7127 11 місяців тому

      @@ClaudioBernasconi Yep, you are right. But it always disturbing for me, when I see colleagues new to professional development, who don't know the difference and try to stuck on VSCode and think "oh, it's newer, it has to be better".

    • @josecarloshurtadoromero5648
      @josecarloshurtadoromero5648 4 місяці тому

      VS search engine and version control assistant are very sluggish compared to VS Code. And those are enough reason for me 😌

  • @maharani8131
    @maharani8131 5 місяців тому

    Sori mang ra fahan

  • @diegodelcastillo6625
    @diegodelcastillo6625 5 місяців тому

    Hello Claudio I'm trying to debug but an api but doesn't work, only appears the next message:
    "Determinando los proyectos que se van a restaurar...
    Todos los proyectos están actualizados para la restauración.
    ApiPruebas -> /home/dcastillo/Documentos/Fullstack/C#/Demos/ApiPruebas/bin/Debug/net6.0/ApiPruebas.dll
    * Terminal will be reused by tasks, press any key to close it."
    After that I press any key vs code spends time loading and don't run

    • @ClaudioBernasconi
      @ClaudioBernasconi  5 місяців тому

      Thanks for your question. I don't know how to resolve your issue. I suggest posting your question on StackOverflow and include as much details as possible, including your project etc.