C# 命名参数Console.WriteLine c

C# 命名参数Console.WriteLine c,c#,console.writeline,C#,Console.writeline,我经常编写Console.WriteLine语句,然后在以后的阶段对其进行修改。然后我以这样的陈述结束 Console.WriteLine("{2} is not greater than {0} or smaller than {1}",min,max, grade); 是否有一种方法可以显式命名传递给Console.WriteLine的参数,这样我就不需要按顺序传递min、max和grade 作为相关说明,我经常删除要在Console.WriteLine中打印的变量,例如下面删除了{2}的

我经常编写Console.WriteLine语句,然后在以后的阶段对其进行修改。然后我以这样的陈述结束

Console.WriteLine("{2} is not greater than {0} or smaller than {1}",min,max, grade);
是否有一种方法可以显式命名传递给Console.WriteLine的参数,这样我就不需要按顺序传递min、max和grade

作为相关说明,我经常删除要在Console.WriteLine中打印的变量,例如下面删除了{2}的地方

Console.WriteLine("{3} is not greater than {0} or smaller than {1}",min,max, grade);
有没有一种方法不改变编号,而是说:

Console.WriteLine("{3} is not greater than {0} or smaller than {1}",{0}:min,{1}:max, {3}: grade);
类似于这样的陈述

@Html.ActionLink("Your profile", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" });
Console.WriteLine($"{grade} is not greater than {max} or smaller than {min}");
与此相反:

Console.WriteLine("{3} is not greater than {0} or smaller than {1}",min,max, grade);
您还可以使用C 6字符串插值语法:

Console.WriteLine($"{grade} is not greater than {min} or smaller than {max}");
与此相反:

Console.WriteLine("{3} is not greater than {0} or smaller than {1}",min,max, grade);
您还可以使用C 6字符串插值语法:

Console.WriteLine($"{grade} is not greater than {min} or smaller than {max}");

现在可以像这样输入字符串

@Html.ActionLink("Your profile", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" });
Console.WriteLine($"{grade} is not greater than {max} or smaller than {min}");
注意字符串前面的$符号。

现在可以像这样输入字符串

@Html.ActionLink("Your profile", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" });
Console.WriteLine($"{grade} is not greater than {max} or smaller than {min}");

注意字符串前面的$符号。

使用C 6字符串插值:${grade}不大于……为什么不使用字符串插值${grade}不大于{min}或小于{max}请注意,字符串中没有自动补全。请使用C 6字符串插值:${grade}不大于……为什么不使用字符串插值${grade}不大于{min}或小于{max}。请注意,字符串中没有自动完成。