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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -