, , ? , ( , ) System.IO TextWriter, ...
:
public class Logger
{
public Logger(TextWriter writer)
{
_writer = writer;
}
private TextWriter _writer;
public void Write(string text)
{
_writer.Write(text);
}
}
Now, is it a good idea to make the publication public and rely on the users of your code to make sure it is always valid? Probably not, but that's more of a design consideration. In addition, your java style setter is A) atypical for C #, which has nice syntactic support for properties, and B) is useless since the support field is public.
source
share