gpt4 book ai didi

c# - string.format 序列能否以任意顺序出现

转载 作者:太空宇宙 更新时间:2023-11-03 18:10:15 25 4
gpt4 key购买 nike

我这里有一个字符串,

return  string.Format("/abcXYZ990099/abc.aspx?IDA={0}&Name={1}&Teacher={2}",
ID, Name, Teacher);

现在由于要求改变了我也需要从数据库中获取“abcXYZ990099”,是否可以做这样的事情,
return  string.Format("/{3}/abc.aspx?IDA={0}&Name={1}&Teacher={2}",
ID, Name, Teacher, NewPropertyValue);

最佳答案

是的,你可以这样做。但是我会重新索引占位符并重新排序参数以适应它们应该出现在返回字符串中的顺序,例如

return  string.Format("/{0}/abc.aspx?IDA={1}&Name={2}&Teacher={3}",
NewPropertyValue, ID, Name, Teacher);

关于c# - string.format 序列能否以任意顺序出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17468596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com