gpt4 book ai didi

c# - ASP.net 有很多具有相同值的文字?

转载 作者:行者123 更新时间:2023-11-30 19:31:27 24 4
gpt4 key购买 nike

给定内容页面上的代码:

Are you sure you want to add another <asp:Literal runat="server" id="Name1" /> to the basket?  
You already have a <asp:Literal runat="server" id="Name2" /> in your basket.
<asp:Literal runat="server" id="Name3" /> has not yet been added to your basket.

然后在代码隐藏中:

Name1.Text = Product.Name;
Name2.Text = Product.Name;
Name3.Text = Product.Name;

我很确定这不是解决问题的最佳方法,是否有我不知道的 ASP.net 功能或设计模式?

最佳答案

为什么不用string.Format

String.Format("Are you sure you want to add another {0} to the basket? You already have a {0} in your basket. {0} has not yet been added to your basket.", Product.Name)

关于c# - ASP.net 有很多具有相同值的文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7178364/

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