gpt4 book ai didi

c# - 将乘法转换为字符串

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

<分区>

转换问题

抱歉,如果这是一个愚蠢的问题,但我是 C# 的初学者。我正在尝试制作一个简单的时间表助手,但在指示的代码行下出现错误:

private void buttonShow_Click(object sender, EventArgs e)
{
try
{
int val = Convert.ToInt32(textBoxVal.Text);
for (int i = 1; i < 13; i = i + 1)
{
listBoxTimes.Items.Add((i * val).ToString()); //'This is the line'//
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
textBoxVal.Text = "";
listBoxTimes.Items.Clear();
}
}

这是错误信息:

Error 1 The best overloaded method match for 'System.Windows.Forms.ListBox.ObjectCollection.Add(object)' has some invalid arguments C:\Users\Chris\Documents\Visual Studio 2012\Projects\sharptimestable\sharptimestable\Form1.cs 27 21 sharptimestable

这一个是关于 .ToString 转换的:

Error 2 Argument 1: cannot convert from 'method group' to 'object' C:\Users\Chris\Documents\Visual Studio 2012\Projects\sharptimestable\sharptimestable\Form1.cs 27 44 sharptimestable

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