不能隐式转换类型产品 [英] Cannot implicitly convert type product

查看:75
本文介绍了不能隐式转换类型产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到两条不同的错误消息,我不知道问题出在哪里,我知道它与第一个产品有关。 'productModel.GetProduct(id);'。



我的代码如下:



 Private void FillPage()
{
if(String.IsNullOrWhiteSpace(Request.QueryString [id]))
{
int id = Convert.ToInt32( Request.QueryString [id]);
ProductModel productModel = new ProductModel();
产品product = ProductModel.GetProduct(id);





最后一行代码包含问题。我得到的错误是:



产品错误消息



F中的产品类型: \产品.aspx'与'App_Code.gmsjomg_,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null'中的导入类型'Product'冲突。使用F:\ Product.aspx'中定义的类型。



ProductModel.GetProduct(id)错误



无法将类型'Product [F:\ App_Code \ Model.cs(25)'隐式转换为'Product [F:\ Product.aspx(12)]'



任何帮助都会非常感激,因为我完全迷失了这些错误,我似乎无法绕过它们。谢谢





我尝试过:



i不知道从哪里开始,在

解决方案

之前我从来没有遇到任何类似的问题。看看这个:当它决定一个类与它自己不同时,绕过Visual Studio ... [ ^ ]

I am getting 2 different error messages and I dont know where the problem is, I know it has something to do with the first 'product' & 'productModel.GetProduct (id);'.

My code is as follows:

Private void FillPage ()
{
if (String.IsNullOrWhiteSpace (Request.QueryString ["id"]))
{
   int id = Convert.ToInt32 (Request.QueryString [id]);
   ProductModel productModel = new ProductModel ();
   Product product = ProductModel.GetProduct(id);



The last line of code contains the issue. The errors I am getting are:

Product error message

The type 'Product' in F:\Product.aspx' conflicts with the imported type 'Product' in 'App_Code.gmsjomg_, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in F:\Product.aspx'.

ProductModel.GetProduct(id) error

Cannot implicitly convert type 'Product [F:\App_Code\Model.cs (25)' to 'Product [F:\Product.aspx (12)]'

Any help would be greatly appreciated as I'm completely lost with these errors I cannot seem to get around them. Thanks


What I have tried:

i dont know where to start with tyring anything ive never had a problem like this before

解决方案

Have a look at this: Getting round Visual Studio when it decides a class isn't the same as itself...[^]


这篇关于不能隐式转换类型产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆