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 is web forms in c#?

0 Answers  


What are the types of constructors?

0 Answers  


What is the use of console readline () in c#?

0 Answers  


What is the difference between add and addrange in c#?

0 Answers  


Can multiple catch blocks be executed?

4 Answers  


Why do we use classes?

0 Answers  


What are destructors in C#?

1 Answers   TryTechnicals Pvt Ltd,


What do you understand by an Implicit Variable?

0 Answers   CGI,


In the page load event I assigned dropdownlist’s datasource property to a valid list. On the submit button click.. The same datasource property is coming as null. Why?

0 Answers  


is it possible to access a remote web service Without UDDI?

0 Answers   TCS,


Can a child class call the constructor of a base class?

0 Answers  


What do you mean by saying a "class is a reference type"?

0 Answers  


Categories