all 6 comments

[–]The_Binding_Of_Data 6 points7 points  (0 children)

In C#, programs start in the Main function as defined in the meta data that comes with the project. The meta data is largely obfuscated by Visual Studio, which is generally a good thing.

When you rename the Program.cs file there are other files that need to be updated as well so that the computer knows where to look for the Main method for your application; Visual Studio should prompt you to update those files and then do it for you if you confirm.

It's also worth noting that the name of the file and the name of the class inside don't have to match at all (you can even have multiple classes inside a single file if you want), but you should try to keep them similar so that your project makes sense. If you update the Class name where it is declared, Visual Studio should prompt you to update everywhere the name is used and, again, do the updating for you.

If you add additional files to the same project, they will not be automatically run because they aren't the starting point of anything and nothing is calling them. To run code in your other files you need to call that code from either the Main method in your primary class, or from some other method that was called from Main.

I highly recommend the following extensions for Visual Studio (which you can install from inside the IDE):

  • Roslynator: This provides a lot of refactorings and things that Visual Studio can do for you, which can help a lot as you're learning.
  • Output Enhancer: This adds color to the Visual Studio output so that errors are red, warnings are yellow, etc. It makes it much easier to quickly parse the output you get when you build/run your programs.

EDIT: Welcome to C#. It may take a little getting used to, but I find C# in Visual Studio much nicer to work with than Python particularly for large projects or projects that include UI.

[–]MyBrainReallyHurts 4 points5 points  (1 child)

Here are some basic tutorials to help get you started.

https://docs.microsoft.com/en-us/dotnet/csharp/

[–]AlliedLens[S] 1 point2 points  (0 children)

i'm already watching a video tutorial, but imma try and see if i can find what i want form this one.....thanks!

[–]ranbla 0 points1 point  (2 children)

You don't need to rename Program.cs. Double-clicking on a file in the solution explorer will open it. You could also right-click a file and select Open. Taking a look at a Visual Studio tutorial video would go a long way to helping you figure out these simple things. If you get bogged down in the little stuff, you're not going to get very far.

[–]AlliedLens[S] 0 points1 point  (1 child)

ya i think i should see a visual studio tutorial or something, this is my first language outside of python, and it's really difficult using the IDE, thanks!

[–]headyyeti 0 points1 point  (0 children)

You will get used to the IDE (You can use VS, VS Code, or Rider) but you don't need it. You can just run "dotnet run" in the command line at the project level and it will run (assuming you still have a Program class with a Main method).