重命名表单后出现冲突警告
在我的第一个项目中,我多次遇到这个警告。阅读警告描述后,我不知道它到底是什么以及如何修复它。我认为当我更改 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您有两种同名的类型。重命名其中之一,清理解决方案,然后重建。
Looks like you have two types with the same name. Rename one of them, clean the solution, and rebuild.
我不能 100% 确定这会解决问题,但您不应该对对象实例使用与对象本身名称相同的名称。在您的屏幕截图中,您正在使用:
以及如果
没有亲自尝试,我不确定是否可以编译,如果可以编译,您可能会遇到运行时问题。至少,对于任何必须维护代码的开发人员来说,阅读起来都会感到困惑。
请记住,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:
as well as
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.