gpt4 book ai didi

c# - 在消息框中显示 报告

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

在我的 WinForm 中,我有一个方法可以检查各种用户控件的有效性并将它们添加到错误列表中。当用户单击保存按钮时,我希望它检查验证方法并在消息框中显示错误(如果有)。 Validate 方法采用另一种形式和类,所以我认为这可能是我的问题。

 private void Save_Click(object sender, EventArgs e)
{
var errorList = string.Join(Environment.NewLine, Validate.ToArray());
MessageBox.Show(errorSet);

}

感谢您的帮助。

最佳答案

错误'Form1.Validate(System.Collections.Generic.List<string>)' is a 'method', which is not valid in the given context意味着您使用的方法错误。

var errorList = string.Join(Environment.NewLine, Validate.ToArray());

没有意义。您缺少括号:

var errorList = string.Join(Environment.NewLine, Validate().ToArray());

这只是一个问题。该方法有一个类型为 List<string> 的参数,但您没有将参数传递给该函数。

此外,您在评论中说返回值的类型为 bool ,但您似乎希望它返回一个字符串集合。

关于c# - 在消息框中显示 <List> 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17992370/

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