You need to copy the method signature from string.format.
public void WriteLine(string text,params object[] args) {
this.StringList.Add(string.Format(text,args));
}
As suggested by ChaosPandion you can also include overloads to prevent array creation
public void WriteLine(string text) {
this.StringList.Add(text);
}
public void WriteLine(string text,object arg0) {
this.StringList.Add(string.Format(text, arg0));
}
public void WriteLine(string text,object arg0, object arg1) {
this.StringList.Add(string.Format(text, arg0, arg1));
}
public void WriteLine(string text,object arg0, object arg1, object arg2) {
this.StringList.Add(string.Format(text, arg0, arg1, arg2));
}
I wouldn’t go past arg2 as string.format doesn’t so the benefit disappears.