Win
Win

Reputation: 62300

Best practice of using HtmlTextWriter with string.Format

Resharping is complaning about string.Format inside HtmlTextWriter.

enter image description here

What will be the best practice using HtmlTextWriter with string.format?

Thank in advance!

Upvotes: 0

Views: 603

Answers (2)

SLaks
SLaks

Reputation: 888185

The Write and WriteLine methods on all of these classes can also take format parameters:

writer.Write("{0} {1}", x, y);

Upvotes: 1

brendan
brendan

Reputation: 29996

The point is that you do not need to use string.Format. You can just do this:

writer.Write("{0}",1);

See: http://msdn.microsoft.com/en-us/library/acsz4w2k.aspx

HtmlTextWriter.Write Method (String, Object[])

Writes a formatted string that contains the text representation of an object array to the output stream, along with any pending tab spacing. This method uses the same semantics as the String.Format method.

Upvotes: 2

Related Questions