C
C#3y ago
bilal94

Can someone explain this for me

namespace CSharp
{
internal class Program
{
static void Main(string[] args)
namespace CSharp
{
internal class Program
{
static void Main(string[] args)
Can someone tell me what this does, as I am new to C#
3 Replies
Thinker
Thinker3y ago
CSharp is like a "folder" that the class Program exists in. Program is a class, something which contains one or more members, for instance methods. Main is a method, something which executes code. This method is very special, because it's called at the very start of your program. Oh and args you don't need to worry about for now, it has to do with what happens when you open your executable file and run the program.
Aeon Vex
Aeon Vex3y ago
also the internal keyword before class Program marks the class as only accessible within this assembly, which is like a bundle of namespaces and classes. you don't need to worry about that for now, just know that your code is always part of an assembly. sidenote: if you were to leave out the internal keyword, the compiler would add it by default. if you're working on a simple project with only one assembly, and you're not writing a library, public and internal are kind of interchangeable, as both are equally accessible to everything within the same assembly. as soon as you start working with multiple assemblies you should know the difference between the two however, and only mark public what should be accessible to other assemblies.
bilal94
bilal94OP3y ago
Thanks guys

Did you find this page helpful?