Which is more conventional in C#?
class Foo
{
private string _first;
private string _second;
public Foo(string first)
{
_first = first;
_second = string.Empty;
}
}
or
class Foo
{
private string _first;
private string _second = string.Empty;
public Foo(string first)
{
_first = first;
}
}
Don’t know about convention, but the safer way is initializing members as in your second example. You may have multiple constructors and forget to do the init in one of them.