重命名表单后出现冲突警告

发布于 2024-11-27 06:28:35 字数 908 浏览 0 评论 0原文

在我的第一个项目中,我多次遇到这个警告。阅读警告描述后,我不知道它到底是什么以及如何修复它。我认为当我更改 winform(.cs 文件)的名称时会发生这种情况。请让我知道这个警告的原因是什么以及如何解决它? 感谢您的帮助。

警告 1 类型“Patience_Management.med” 'C:\Users\TNhan\documents\Visual Studio 2010\项目\Patience_Management\Patience_Management\Class1.cs' 与导入类型冲突“Patience_Management.med” 'c:\Users\TNhan\Documents\Visual Studio 2010\Projects\Patience_Management\Patience_Management\bin\Debug\Patience_Management.exe'。 使用 'C:\Users\TNhan\documents\visual studio 中定义的类型 2010\项目\Patience_Management\Patience_Management\Class1.cs'。 C:\用户\TNhan\文档\视觉 工作室 2010\Projects\Patience_Management\Patience_Management\kham.cs 17 9 Patience_Management

也许这张图片有帮助。警告消息出现在绿色下划线处。 http://www.freeimagehosting.net/newuploads/a58e0.png

In my first project, I encountered this warning many times. After reading the warning description, I don't know exactly what it is and how to fix it. I think it occurs when I change the name of winform(.cs file). Please let me know what is the cause of this warning and how to fix it?
Thanks for your help.

Warning 1 The type 'Patience_Management.med' in
'C:\Users\TNhan\documents\visual studio
2010\Projects\Patience_Management\Patience_Management\Class1.cs'
conflicts with the imported type 'Patience_Management.med' in
'c:\Users\TNhan\Documents\Visual Studio
2010\Projects\Patience_Management\Patience_Management\bin\Debug\Patience_Management.exe'.
Using the type defined in 'C:\Users\TNhan\documents\visual studio
2010\Projects\Patience_Management\Patience_Management\Class1.cs'. C:\Users\TNhan\documents\visual
studio
2010\Projects\Patience_Management\Patience_Management\kham.cs 17 9 Patience_Management

Maybe this image helps. The warning message appear at the green underline.
http://www.freeimagehosting.net/newuploads/a58e0.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

偏闹i 2024-12-04 06:28:35

看起来您有两种同名的类型。重命名其中之一,清理解决方案,然后重建。

Looks like you have two types with the same name. Rename one of them, clean the solution, and rebuild.

哆兒滾 2024-12-04 06:28:35

我不能 100% 确定这会解决问题,但您不应该对对象实例使用与对象本身名称相同的名称。在您的屏幕截图中,您正在使用:

addPatience addPatience = new addPatience(TextBox1.Text);

以及如果

kham kham = new kham // rest of line ommitted

没有亲自尝试,我不确定是否可以编译,如果可以编译,您可能会遇到运行时问题。至少,对于任何必须维护代码的开发人员来说,阅读起来都会感到困惑。

请记住,C# 区分大小写。

I'm not 100% sure this will fix the problem, but you should not use the same name for an object instance as the name of the object itself. In your screenshot, you're using:

addPatience addPatience = new addPatience(TextBox1.Text);

as well as

kham kham = new kham // rest of line ommitted

Without trying it myself, I'm not sure that would even compile, and if it did you might have run-time issues. At the very least, it would be confusing to read for any developer that would have to maintain your code.

Remember, C# is case-sensitive.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文