Prior to C# 10.0 a struct
could only have constructors that took parameters. Any initialization had to use a static method or a factory method.
Code
C#
public struct Container
{
public Container()
{
CreatedAt = DateTime.Now;
}
public string Name { get; set; }
public DateTime CreatedAt { get; set; }
}
C#
public struct Container
{
public Container(string name)
{
Name = name;
CreatedAt = DateTime.Now;
}
public string Name { get; set; }
public DateTime CreatedAt { get; set; }
}