Visual studio 警告 - 类型冲突

Visual studio warning - type conflict

这个警告让我抓狂。

Warning CS0436 The type 'TypeName' in TypeAddress conflicts with the imported type 'TypeName' in 'TypeAddress

TypeNames 和 TypeAddress 完全相同。

为什么 Visual studio 警告我这个?

您在同一个命名空间中定义了两次,这是不允许的(或者更准确地说,其中一次被忽略)。例如。一次在您的主程序中,一次在它引用的项目或库中。您需要删除其中一个定义。

如果找不到它,请确保您的构建是最新的,方法是执行清理解决方案或重建解决方案。

有关详细信息,请参阅:https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0436