Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个随机数生成器,屏幕上有 6 个标签,每个标签名为 num1、num2 等。
当用户按下随机按钮时,调用的代码是
Random RanClass = new Random(); num1 = RandomClass.Next(1,6);
我得到的错误是说你不能将 int 转换为 System.Web.UI.WebControlsLabel
如何将生成的随机数放入标签中?
你只需要设置Text属性
Text
num1.Text = RandomClass.Next(1,6).ToString();