what does static void Main(string[] args) in C# mean????????

Answers were Sorted based on User's Feedback



what does static void Main(string[] args) in C# mean????????..

Answer / subhash

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

what does static void Main(string[] args) in C# mean????????..

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

what does static void Main(string[] args) in C# mean????????..

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

what does static void Main(string[] args) in C# mean????????..

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

what does static void Main(string[] args) in C# mean????????..

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

Post New Answer

More C Sharp Interview Questions

What's the difference between a static method and a non static method c#?

0 Answers  


What is parsing? How to parse a date time string?

0 Answers  


Describe the process of “exception handling implementation” in c#?

0 Answers  


What type of data type conversion happens when the compiler encounters the following code?

0 Answers  


Name the two classes are required for implementing a windows service?

0 Answers  






What is the default value of boolean variable?

0 Answers  


what are the files we need to deploay a project in the system?

2 Answers  


what is Anonymous Method.? and What is shadowing?

2 Answers   ATS, Infosys,


How does split work in c#?

0 Answers  


What is the syntax for calling an overloaded constructor within a constructor?

0 Answers  


What is a must for multitasking

0 Answers   InterGraph,


Why should I use interface in c#?

0 Answers  


Categories