C # string.format add value "-"?

I have a problem with string.format ...

I try to pass my account ID as an argument to my program ... and the 6th argument always ends with a "-" no matter what I do (we have to use ¿because of the old program) ...

     public static void OpenIdInvoice(string wdlName, string IdInvoice, Form sender){
        MessageBox.Show(string.Format("¿{0}",IdInvoice));
        proc.Arguments = string.Format("{0}¿{1}¿{2}¿{3}¿{4}¿­{5}",
            session.SessionId.ToString(),
            Session.GetCurrentDatabaseName(),
            session.Librairie,
            wdlName,
            "",
            IdInvoice
        );
        System.Windows.Forms.MessageBox.Show(proc.Arguments);

In the end, “-” is always added to my formatted result, but only until my IdInvoice ... (so Id 10 ends with -10 in my arguments)

now the interesting part ... I hardcode the string and ...

if I pass -1 instead of Id, I have -1 as a result, and if I write "banana" ... I get "-banna" ...

I know that I could just build a string otherwise ... but I'm curious why this is happening.

Here is a screenshot minus a banana?...

EDIT:

/

var proc = new System.Diagnostics.ProcessStartInfo("Achat.exe");
        System.Windows.Forms.MessageBox.Show(string.Format("¿{0}",args));
        proc.Arguments = string.Format(@"{0}¿{1}¿{2}¿{3}¿{4}¿­{5}¿{6}",
            "12346", //session.SessionId.ToString(),
            "fake DB",//Session.GetCurrentDatabaseName().ToString(),
            "false", //session.Librairie.ToString(),
            "myScreenName", //wdl.ToString(),
            "123456",
            "Banana",
            "123456"
            //args.ToString(), 

        );
        System.Windows.Forms.MessageBox.Show(proc.Arguments);
        System.Windows.Forms.MessageBox.Show(args);

/ :

12346. DB¿false¿myScreenName¿123456¿BananaÀ123456

+6
1

"{5}", . , . "{" "{5}" , "", . , Notepad ++, . ,

var t = @"{0}¿{1}¿{2}¿{3}¿{4}¿­{5}";
foreach (var c in t)
{
    Console.WriteLine((int)c + " " + c);
}

123 {
48 0
125 }
191 ¿
123 {
49 1
125 }
191 ¿
123 {
50 2
125 }
191 ¿
123 {
51 3
125 }
191 ¿
123 {
52 4
125 }
191 ¿
173 -
123 {
53 5
125 }
+5

Source: https://habr.com/ru/post/1016015/


All Articles