Library tutorials & articles
Program Entry point in C#
By Kamran Shakil, published on 13 Mar 2002
Page 4 of 5
- Introduction
- Example 1 & 2
- Example 3 & 4
- More Examples
- Additional Examples
More Examples
kamran.cs
Compiler Error
The signature also includes modifiers like static etc. It just proves the importance of the function Main and the way it has been defined.
kamran.cs
Compiler Error
The error proves the point that you cannot have two different classes, zzz and yyy, containing Main. Only one occurrence of Main is allowed. You always have only one chance of a lifetime. Ditto with Main.
kamran.cs
Output
The access modifiers are not included within the signature for Main. Even though Main is made private, it is considered as an entry point function, hence hell gets displayed. This function is unique and works as a special case.
class zzz
{
public void Main()
{
}
}
Compiler Error
error CS5001: Program 'kamran.exe' does not have an entry
point defined
The signature also includes modifiers like static etc. It just proves the importance of the function Main and the way it has been defined.
kamran.cs
class zzz {
public static void Main()
{
}
}
class yyy
{
public static void Main()
{
}
}
Compiler Error
kamran.cs(3,20): error CS0017: Program 'kamran.exe' has
more than one entry point defined: 'zzz.Main()'
kamran.cs(3,20): error CS0017: Program 'kamran.exe' has more than one entry point
defined: 'yyy.Main()'
The error proves the point that you cannot have two different classes, zzz and yyy, containing Main. Only one occurrence of Main is allowed. You always have only one chance of a lifetime. Ditto with Main.
kamran.cs
class zzz
{
private
static void Main()
{
System.Console.WriteLine("hell");
}
}
Output
hell
The access modifiers are not included within the signature for Main. Even though Main is made private, it is considered as an entry point function, hence hell gets displayed. This function is unique and works as a special case.
Related articles
Related discussion
-
How to Export Datagridview contents to Excel
by BarbaMariolino (8 replies)
-
Very Urgent regarding deleting the images from a folder
by nike12 (1 replies)
-
Help accessing sound card
by daz4904 (0 replies)
-
How to Write a GPS Application
by stoyac (19 replies)
-
class file in C#
by glad024 (0 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
I am not discouraging you, but I just dont see a need for an article on this issue. One can find out those errors on trial and error basis with a test program. Give us something new and creative!
This thread is for discussions of Program Entry point in C# .