Fun With Named Formats, String Parsing, and Edge Cases
Posted by: youve been HAACKED,
on 05 Jan 2009 |
View original | Bookmarked: 0 time(s)
Recently I found myself in a situation where I wanted to format a string using a named format string, rather than a positional one. Ignore for the moment the issue on whether this is a good idea or not, just trust me that Ill be responsible with it. The existing String.Format method, for example, formats values according to position. string s = string.Format("{0} first, {1} second", 3.14, DateTime.Now);
But what I wanted was to be able to use the name of properties/fields, rather...