92 Replies
Input arguments passed into the application
Said arguments are passed when, e g. running a console application from the command line
Then why is is string [] args and not just method (some value)
Not sure what you are asking. string[] is an array of strings. Meaning you have multiple strings
Each representing an argument
Also what application? Do you mean program?
Yes
Main() and command-line arguments
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
Either a console based application or a GUI application such as WinForms or WPF
Okay but i could've done it without args
Just string []
If its an argument
?
args is the name of the input parameter
You cannot ommit it
you can leave the parameters out completely if not needed
Ommit what
Im way too confused now
I have a method and put some value in it so its method (value)
I thought you meant the Main method
Main is also a method
When you use a method, you do indeed put a value into it
can you post some $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/When you define a method, that can be used, you have to write it's parameters. Each parameter must have a data type and a name
Of course, you can have a method without parameters
E.g.:
Its from w3school
what's the issue
I don't know what string[] args is
a parameter
What parameter
A parameter for receiving command line arguments
Yeah I dont know what command line is
Ok I'll try and explain
Have you run a Console application yet? A black window appears with, e.g., some text
Yeah
That black window is called Command prompt in Windows. You can open it by searching command prompt
Or CMD for short
So its just input to console?
Command line I mean
I don't have my pc with me
And in it, you enter commands. You can call a command and specify arguments to it
If you'd call a c# console program a give an argument to it, you'd receive it via the args parameter
Couldn't you just do console.WriteLine ()
Method (console.ReadLine ())?
No this is something different
Whats args?
Here the main method is being defined, not called
Yeah I know
You don't call the main method, as it is a special method. It is called when an application is started
And sometimes you don't want to do readline
Is main method different than other methods?
You want to specify arguments straight away
I mean you can use both same way
But this method I posted isn't in Main
But I can see main
Wait you're right Im confused how is it in a class
Main is always in a class
But it is true that it shouldn't be in Car
Doesn't really make sense there
It is usually in the Program class
Ok back to my question what is string[] args
-v is an argument
You get v into your program via the string[] args method parameter
node is some program
Im confused about all these parameters and arguments
I mean I read what they are
And I still don't get it
You just wrote program and added "-v" to it
It's not really something you should worry about now, to be honest. However, it'd be best if you tried it out. Figure out how to run a Console application from the command prompt
Yes -v is some argument
Its a string
An extra value
Yes
Not an argument
String is a data type
Argument is a value of some data type, that a program receives as input
So arguments are just inputs?
Yes
THEN CALL THEM INPUTS😭
So string[] args is adding a value to a method?
In a string
Or series of them as it uses []
string [] args means that a method receives a set of strings, that represent input arguments
String[] is an array of strings
And I seperate them with "," right?
Does it just add text to a method or somehow change it how it may work?
Usually with spaces. I'm not too well versed with command line argument processing
Based on what your main method gets via the
string[] args
you usually change how your program behavesIts just a text
It won't change a number
You'd write, e.g., if conditions check is the
args
contains a specific string. And if it does, you do somethinga parameter itself does nothing
Ok and args is ALWAYS an input
what
.
.
sure
And args are a type of parameter
a string array to be exact
That you use in method
Right?
if you introduce a parameter in the method signature, you usually do something with it
otherwise don't
Whats signature?
The way a method is defined
Like static?
Methods - C# Programming Guide
A method in C# is a code block that contains a series of statements. A program runs the statements by calling the method and specifying arguments.
private void MyMethod(int input)
This is a signature
no
My suggestion is to ignore the specifics such as the string[] args, and focus on c# fundamentals
start practising with $helloworld
Written interactive course https://learn.microsoft.com/en-us/users/dotnet/collections/yz26f8y64n7k07
Videos https://dotnet.microsoft.com/learn/videos
I just thought I should know what different things do if I want to know how code works
I feel that you are missing a lot of crucial knowledge to fully understand our explanations...
That is true
However, you can't understand everything at once... Unfortunately
Ok so for now
parameter is additional information for a method
Argument is an inputted parameter
Sigantures are things like public and void
well
Well, not exactly
Im just a begginer😭
The signatures part isn't quite right
nor is the argument
it's not "inputted"
as in a user types something
We know, no stress. We had to give you a lot of new information here and it is quite overwhelming
but to me, this is kinda going nowhere. Better to start doing and learn as you go
Ok I appriciate your help thank you very much<:millia_love:856302466030370846>
Keep learning, don't give up. You've got a long and exciting road ahead of you. And don't hesitate to ask more questions, even if you might get a headache from the answers....
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.