what does static void Main(string[] args) in C# mean????????
Answers were Sorted based on User's Feedback
This can be explained as below
public : since the method will be accessed by the other
classes(.net runtime). That is why access modifier is Public
Static:
.net runtime environment call static method of the class
where main is defined. By making Main method as static .net
runtime environment do not need to make object of the class.
runtime environment call the method something like as stated
below.
Class A
{
A()
{}
public static void Main(string[] agrs)
{
}
}
.net Runtime-->
A.Main(args)
Void :
Main method does not return anything
(string[] args):
Here we can pass any number of parameter to the class.
lets say we are making an exe taking 2 parameters then we
can pass parameters to the main method
Is This Answer Correct ? | 89 Yes | 8 No |
Answer / elan
It is the code starting point and when a function specified with static it will be always available in App Domain (in application). Also no need to create any instance and Classname.Function / Method name will work. The usage of string args[] is read the command line argument.
Is This Answer Correct ? | 23 Yes | 5 No |
Answer / basha
In C# language CLR (common language run time) compiler program Execute from Main() method only In this declare static keyword we can't create instance to that method (or) class.
Example:
class A // step 3: class A is declare
{
public void Main()//step 4: In class A have contain a method Main. In this method contain print some text
{
Console.WriteLine("main method call");// step 5: by call main method to print this text.
}
}
class B
{
public static void Main() //step 1: Execute program form this
{
A obj = new A();// step 2: after compiler check here what is A? here A is class creating object to class A.
obj.Main(); // step 6:print text from Main() method in class A
}
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / cc
WriteLine is a procedure/ method in the class called Console.
It doesn't have any relation with Static keyword.
Void is called "nothing" or no more return type required by the function.
Static is a keyword used by Main method because to avoid manipulation of Main Function.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vaibhav durhaya
in C# Main function returns something as string. If u dont
want something return to function u have to use Void. And
Static Keyword shows that there should be something in the
function which is static, i.e. WriteLine() is a static
member method of the Console class.
Is This Answer Correct ? | 42 Yes | 49 No |
the selected inf of other combobox?How do you achieve it?
What is the advantage of constructor in c#?
How do I get deterministic finalization in c#?
What is serialization in .net?
What exactly happens when we debug and build the program?
What is unsigned int?
Can we have a non static member function in a base class to be override in derived with static modifier?
What is the components of window?
What is delay signing..??
What can you do as a .net developer?
How to make a class not inheritable other than sealed?
What is the difference between writeline and write in c#?