Jean Tehhe Jean Tehhe - 18 days ago 9x
ASP.NET (C#) Question

call to resx with parameters

I've resx file for translation in my project and I want to replace all the text
that will become from this file,when I use text without parameters like following its working

objRes.ErrorMsg = Group.err_message_duplicate;//This replace the entire string

The problem is that I want to replace the following strings

objRes.ErrorMsg = "user " + username + " doesn't exist in" + table;

For it I create in the resx file the following entry

User {0} doesn't exist in {1}

How should I use the regx with parametes


Use string.Format:

objRes.ErrorMsg = string.Format("User {0} doesn't exist in {1}", username, table);

If coming from the variable Group.err_message_duplicate, use this:

objRes.ErrorMsg = string.Format(Group.err_message_duplicate, username, table);