C
C#3mo ago
IamMax420

why is there "string[] args" inside the main function parentheses?

Hello, I've just started learning c# (after doing some c++) and I wonder why it's like that since we don't even use it inside the main function, like it's just there and I'd like to know why
8 Replies
leowest
leowest3mo ago
its just the default signature template of Main used when u create a console project, you can also make it Main()
TheRanger
TheRanger3mo ago
its optional, you dont have to put it
Jimmacle
Jimmacle3mo ago
you can use it, it's the same as argc/argv in c++ it contains the arguments used to run the program
TheRanger
TheRanger3mo ago
if you run in cmd
yourprogram.exe hello world
yourprogram.exe hello world
the first element in the array would be "hello" and the 2nd element in the array would be "world"
Jimmacle
Jimmacle3mo ago
the first argument is the full path to the executable, no?
IamMax420
IamMax4203mo ago
Ok thanks guys, I get it now
TheRanger
TheRanger3mo ago
No i dont think so not in c# atleast
Jimmacle
Jimmacle3mo ago
seems like you're right