I have static class as container for some static strings:
public static class Constants
{
public static string ERROR_MESSAGE_LOGIN= "Unable to login with {0}";
public static string ERROR_MESSAGE_SEND_MAIL= "Unagle to send mail to {0}";
public static string GetFormatedString(string constantName, object [] params)
{
return
string.Format((string)typeof(Constants).GetField(constantName).GetValue(null),params);
}
}
As you can see I want to return formatted string, that based on name provided. And it is seems to work. However, when I writing method call in some other class I want that it give me list of suggestion for first parameter that contains "ERROR_MESSAGE_LOGIN" and "ERROR_MESSAGE_SEND_MAIL".
I know that I can create enum with those name or just use it like
Constants.GetFormatedString(Constants.ERROR_MESSAGE_SEND_MAIL, someparams);
But is there any way to tell method there is list of string parameters that you accept and show it to user?
Thank you.
Aucun commentaire:
Enregistrer un commentaire