How to make string.Format template more readable? Have a look to the following example. Clearly it's very hard to understand the meaning of each parameter passed to the string.Format to be replaced to the numeric sequence of {0}, {1}, ...

I want to improve the software quality: Maintainability\Code readability
http://en.wikipedia.org/wiki/Software_quality

The problem is also bound to the difficulty of associating numbers to the corrisponding values in the template. i.e. at a first glance what is the meaning of {8}?

               @"&lt;?xml version='1.0'?&gt;
                &lt;RemoteXMLData&gt;
                    &lt;Username agent_diff_type=""{10}"" usertype=""{5}"" ticket_language=""{6}"" min_slip_stake=""{7}"" max_stake=""{8}"" location=""{9}""&gt;{0}&lt;/Username&gt;
                    &lt;Password&gt;{1}&lt;/Password&gt;
                    &lt;Reseller&gt;{2}&lt;/Reseller&gt;
                    &lt;Function&gt;AutoLogin&lt;/Function&gt;
                    &lt;AppKey&gt;{3}&lt;/AppKey&gt;
                    &lt;Sub&gt;{4}&lt;/Sub&gt;
                &lt;/RemoteXMLData&gt;";


What should I change?

string autoLoginRequest = String.Format(
AutoLoginRequestTemplate, 
username, 
password,
Config.Val1, 
Config.Val2,
requestSub, 
Language, 
minValue,
maxValue, 
agentDiffType);
Like @jesse said you can have a custom method, maybe pass a user object to that method.
Something like this:

class User
{
    public int AutoLoginRequestTemplate { get; set; }
    public string username { get; set; }
    public string password { get; set; }
    public string Val1 { get; set; }
    public string Val2 { get; set; }
    public string requestSub { get; set; }
    public string Language { get; set; }
    public int minValue { get; set; }
    public int maxValue { get; set; }
    public int agentDiffType { get; set; }


    /// &lt;summary&gt;
    /// Formats the user info.
    /// &lt;/summary&gt;
    /// &lt;param name="user"&gt;The user object.&lt;/param&gt;
    /// &lt;returns&gt;A formated string&lt;/returns&gt;
    public string FormatUserInfo(User user)
    {

        return String.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}",
                                user.AutoLoginRequestTemplate,
                                user.username,
                                user.password,
                                user.Val1,
                                user.Val2,
                                user.requestSub,
                                user.Language,
                                user.minValue,
                                user.maxValue,
                                user.agentDiffType);
    }
}




Your question changed, now I see that you are trying to create an xml string.

For the sake of readabilty, I wouldnt use string.Format(), instead I would just do simple concatenation:

"&lt;Password&gt;"+passowrd+"&lt;/Password&gt;"


Now I am not sure about performance, but here we are talking about readability (you probably can spend your time being productive at something else rather than trying to decide which type of concatenation is more efficient/readable)

Now in terms of best practice, I wouldn't create xml manually (just like I wouldnt try to create a JSON or CSV parser) instead I would use .NET framework to do this, which would certainly make it more readble, something like this:

        XElement xml = new XElement("RemoteXMLData",
            new XElement("Username",
                new XAttribute("agent_diff_type", agentDiffType),
                new XAttribute("agentDiffType", agentDiffType),
                new XAttribute("usertype", userType),
                new XAttribute("ticket_language", Language),
                new XAttribute("min_slip_stake", minValue),
                new XAttribute("max_stake", maxValue),
                new XAttribute("location", location),
                username),
            new XElement("Password",
                password),
            new XElement("Reseller",
                reseller),
            new XElement("Function",
                function),
            new XElement("AppKey",
                appKey),
            new XElement("Sub",
                sub)
        );