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 |
Why dictionary is used in c#?
Explain the difference between a sub and a function in c#.
What are the different states of a thread?
What is clr in c#?
Is string null or empty?
What is difference between interface inheritance and class inheritance ?
If i have 100 objects in my application are out of scope.when first time garbage collected how many objects memory reference are free?
What is tpl in c#?
What is sqlconnection in c#?
What is the correct way of declaring an xml namespace?
Explain the role of the datareader class in ado.net connections?
What is difference between private and static constructor?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)