When initializing in C# constructors what's better: initializer lists or assignment?
- by user260197
Class A uses an initializer list to set the member to the paramter value, while Class B uses assignment within the constructor's body.
Can anyone give any reason to prefer one over the other as long as I'm consistent?
class A
{
String _filename;
A(String filename) : _filename(filename)
{
}
}
class B
{
String _filename;
B(String filename)
{
_filename = filename;
}
}