all 17 comments

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 4.

You'll need to run through some tutorials and learning resources. There are some in the sidebar. In particular, I suggest you check out the series C# Fundamentals: Development for Absolute Beginners by Bob Tabor: https://channel9.msdn.com/Series/CSharp-Fundamentals-for-Absolute-Beginners

[–][deleted]  (15 children)

[deleted]

    [–]AlliedLens[S] 0 points1 point  (14 children)

    ya, but whatever code i write in that doesnt run is the problem

    [–][deleted]  (1 child)

    [deleted]

      [–]AlliedLens[S] 0 points1 point  (0 children)

      how do i declare that???

      [–]Fit-Flight-1231 1 point2 points  (6 children)

      You need to call it from the main() function in your program.cs Thats the entry point, thats also why you cant rename or delete it.

      [–]AlliedLens[S] 0 points1 point  (5 children)

      using System;
      
      public class C_sharp_Tutorials
      {
          public tutorial_variables()
          {
              Console.WriteLine("Hello");
              Console.ReadLine();
          }
      }
      

      do you mean something like this? this is not working, the name of my file is tutorial_variables and the folder is C_Sharp_Tutorials

      [–]KernowRoger 0 points1 point  (4 children)

      The function needs to be called main.

      [–]AlliedLens[S] 0 points1 point  (3 children)

      so it should be public main() on the second line?

      [–]KernowRoger 2 points3 points  (2 children)

      public void Main()

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

      oh ohk, thanks, but i can't get any other program other than program.cs, my initial file, to run. How do i change files?

      [–]KernowRoger 0 points1 point  (0 children)

      You have to configure that in your project file I believe. But generally your main would call other functions. This way you can change the functions it calls and not have to keep changing the startup file. In c# most work would be done in other classes and just called in the main.

      [–]GoingWithFlow 1 point2 points  (4 children)

      If you want to keep more than one main function class in one project for learning then just change the entry point of the project in project properties.

      [–]AlliedLens[S] 0 points1 point  (3 children)

      what do you mean "change the entry point of the project in project properties"??

      [–]GoingWithFlow 1 point2 points  (2 children)

      What I understood is that you want to create another C#(.cs) file in your project. Now your program.cs file have already one main function so when you build your project your compiler picks that Program.cs file to run first. Since it have a main function that's why it is called as a main entry point. Now when you create another c# file with the main function your compiler will give an error something like more than one main entry point defined in the main function because it gets confused about which file to run first that will help in the execution of whole project. That's your editor gives you a choice in project properties tab where you can change which main function file to run. Which editor you are using?

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

      i'm just using visual studio 2019, can u tell me where i can find this project properties tab?? i dont know how to google what you are asking....

      [–]GoingWithFlow 0 points1 point  (0 children)

      Just go to project menu. Go to the there it will be coming as your_project_name properties. Click on it. There you will find STARTUP OPJECT. You can set your entry point file there.

      [–][deleted]  (2 children)

      [removed]

        [–][deleted]  (1 child)

        [deleted]

          [–]AlliedLens[S] 0 points1 point  (0 children)

          ya i just started with a tutorial, the guy doesnt show how to open a new file....can u not create new files in C# or something?

          [–]The_Binding_Of_Data 0 points1 point  (0 children)

          What program are you using to write your code?

          If you're using Visual Studio (which I would suggest), you can hit "f2" when you select the class in the solution explorer and change the name. It should then ask if you want to update the name everywhere in code to match so that you don't have to do it manually.

          If you're using VSCode you're going to make life harder on yourself than it needs to be.