C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
14
Reply
Why main function is static?
Swati Agarwal
13y
10.3k
1
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
static is the key word is indicate in .net that, it can not be changed. while main is key word to indicate the main portion of application from where application is started. so the main entry point of application is fixed can not be changed as definition. but we can change its implements. so this is static.
Mahesh Patel
13y
4
Static is modifier used in C# : 1) When applied to a class - the class cannot be instantiated - i.e you cannot use the new keyword to create object (instance) of the class and you can directly accesses the members of the class. 2) A static class has static member and a private constructor ( and so we cannot create object of this class. 3) if you try to create object of a static class you would get a compile time Error. 4) When applied to a method - this method is always accessible by the class name.
Hussain Patel
10y
2
Static is modifier used in C# : 1) When applied to a class - the class cannot be instantiated - i.e you cannot use the new keyword to create object (instance) of the class and you can directly accesses the members of the class. 2) A static class has static member and a private constructor ( and so we cannot create object of this class. 3) if you try to create object of a static class you would get a compile time Error. 4) When applied to a method - this method is always accessible by the class name.
Hussain Patel
10y
0
static function do no require object to execute all the objects of classes are creating inside the main function
Rahul Prajapat
10y
0
static function do no require object to execute all the objects of classes are creating inside the main function
Rahul Prajapat
10y
0
static function do no require object to execute all the objects of classes are creating inside the main function
Rahul Prajapat
10y
0
static function do no require object to execute all the objects of classes are creating inside the main function
Atul Rawat
10y
0
Static give the memory compile time.
Joginder Banger
11y
0
For calling (executing) Each and every function, we need object of their related class. the reason behind to make a main function static. it will free from object, means it will call automatically without object when program will run. for executing static function there is no need to object. it only accessed by its class name. so main function is defined static. because main function is the entry point of executing program.
amit
11y
0
static is used to preserve memory at compilation time.so,that main function will be stored in memory any will be executed.
keerthi rakasi
12y
0
Every C# program of main is Entry Point of the execute the code.we know that static keyword is single copy in to memory.static keyword are without instanse.so it is use of static keyword in main function.
amir ansari
12y
0
The static keyword indicates that it is single copy in to memory As main is entry point to execute the code so is is static and it doest require any object calling
vipul handa
12y
0
as main function is entry point in execution and static keyword need not require any object for calling main function, so program starts directly from 'static main' in class
shrikant mule
12y
0
Main is the entry point for an application and to access the entry point from any where in an application that's why main is static.
Krishna Garad
13y
0
What happens from the point an HTTP request is received on a TCP/IP port up until the Page fires the On_Load event?
What are ASHX files?
Message