c# - String.Format() not invoking custom formatter -
i have custom formatter specified, this:
public class notationnumericformatter : iformatprovider, icustomformatter { public object getformat(type formattype_) { homecoming (formattype_ == typeof(icustomformatter) ? : null; } public string format(string format_, object arg_, iformatprovider formatprovider_) { if (!equals(formatprovider_) || arg_ == null) // <-- set breakpoint here... { return; } // bunch of stuff happens here. } }
what's stumping me @ moment is, next code:
// _myformatter notationnumericformatter gets instanced // in ctor of class in question. var result = string.format(_myformatter, (parameter_ ?? "").tostring(), value_);
which never, ever, hitting first line in formatter's format()
method. missing here? there subtlety string.format
i'm missing?
if parameter not have {0} formatter won't break point
this breakpoint
var result = string.format(_myformatter, "{0}", value_);
this won't
var result = string.format(_myformatter, "", value_);
c# string-formatting
No comments:
Post a Comment