Visual Studio Issue

I am trying to learn C#. However, when I try to start a project in Visual Studio to input C# code into to test programs by running them, Console app (.NET Framework) doesnt even load, it just loads endlessly. Starting a Console App (.NET Core) project does actually open, but doesnt recognice a working C# program such as

for (int x = 0; x < 10;  x+=3 )


I got this program off a website so it should work. It just gives me errors involving the “<” and “;”. What Project setting must I use to input C# code to test running programs?

github also did not let me post Brackets in the previous post, to state the program that I tried to run

I would have to look at your project source code to determine why you are having this problem. My feeling is that you have syntax errors that are stopping your project from building. You need the correct format of special characters like {} in order for the build to succeed.

My suggest, use a specific editor for C# or phpStorm(NOT free) or others. Personally I don’t like that editor too much

C# is a  purely  object oriented language. In fact, boldtext isn’t enough, allow me to say that it is a purely object oriented language. In C#, every little abstraction or data structure is represented by a class. I don’t know what programming language you come from (or if you have any programming experience at all) but this is in contrast to other languages such as C++ and Python.

In Python, your code can run anywhere. The first line of command is the entry point.* You can declare variables anywhere and put conditional statements anywhere. In C++, while you don’t need to write classes for everything, you still need an entry point in your program. It’s usually int main() and it may or may not include arguments. “Global” variables can be declared outside of the main scope but you can’t run conditional statements outside of the scope or functions. 

In C#, you need the bare minimum of the Program class and the Main() void.

Using Visual Studio, here’s what the program should look like in its entirety. 

using System;

namespace myProgram
    class Program
	static void Main(string[] args)
	    for (int x = 0; x < 10; x += 3) {

So, 3 things here to remember about C#:

  • Code you want to execute needs to be inside of a function
  • A function must be inside of a class
  • A program needs an entry point in order to execute. 

(The spam filter caught my post because I kept editing the formatting)

* Slightly misinformative. Python doesn’t really have an “entry point” like traditional programming languages do. The entry point is the file itself, and it just runs every command in order. Sorry for being so specific but you seem new to programming, so I want to make sure you grasp every topic well and understand how software architecture works. 

1 Like

Visual Studio is a very powerful IDE, and if OP is developing on Windows, then I would highly recommend he use Visual Studio for C# as that is the most native-level support he will get for the language. However, if Visual Studio is just a no-go, then MonoDevelop also works and can be used cross-platform for Linux and Mac.