-
-
Notifications
You must be signed in to change notification settings - Fork 108
How Tos
Tareq Imbasher edited this page May 26, 2025
·
2 revisions
The primary approach is to write Top-Level statements, ie:
var p = new Person
{
Id = 1,
Name = "John Doe"
};
p.Dump();
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
To have a "Program" style script and a static Main()
entry point, put it in a partial class Program
:
partial class Program
{
static void Main()
{
var p = new Person
{
Id = 1,
Name = "John Doe"
};
p.Dump();
}
}
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
Another option without the class wrapper is:
void Main(string[] args)
{
var p = new Person
{
Id = 1,
Name = "John Doe"
};
p.Dump();
}
Main(args);
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}