c# 4.0 - C# String.Format and object as argument -
here idea reading string .resx file
and here sample of such string :"i writing {}"
i wrote function pass values arguments. don't know number of arguments expected string
public string myformattedstring (string resourcename, object param=null) { string fstr= resources.resourcemanager.getstring(resourcename); fstr= string.format(fstr, param); return fstr; }
if call function myformattedstring ("resourcename", "nowhere"), not expecting what's wrong?
i found solution issue using params object[] discovered
public string myformattedstring (string resourcename, params object[] param) { string fstr= resources.resourcemanager.getstring(resourcename); fstr= string.format(fstr, param); return fstr; }
Comments
Post a Comment