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 |
What are the two uses of a ‘using’ statement in c#?
When should I throw an exception?
What is the difference between and xml documentation tag?
What are the different approaches of passing parameters to a method?
How to create events for a control? What is custom events? How to create it?
What is managed or unmanaged code?
Difference between string and stringbuilder?
what are the advantages of c# over vb.net?
10 Answers Choice Solutions, HCL, Practical Viva Questions,
Can variables defined in interface. If yes how we can call/use it in class.
If the interface in c# only contains the declaration of the methods and we need to define those methods in the class, then why we use the interface?
Does C# support multiple inheritance?
What are sessions in c#?
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)