Get The Most Out Of Your Format String
Posted by: youve been HAACKED,
on 15 Feb 2006 |
View original | Bookmarked: 0 time(s)
I was reviewing some code when I ran into code that fit this pattern all over the place (simplified to make a point).
string format = "/comments/{0}/{1}.aspx#";string url = String.Format(CultureInfo.InvariantCulture, format + entity.Id, entity.ParentID, entity.Date.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture));
There are a couple things I want you to notice here. The first is concatenation of the entity id to the end of the format string.
format + entity.Id
Second, notice format string...