无法从byte()类型转换为integer()类型 [英] cannot convert from type byte() to type integer()

查看:138
本文介绍了无法从byte()类型转换为integer()类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在数据网格中显示图像....



m trying to display images in datagrid....

<img alt=""  runat="server" src='<%# "GetImage.aspx?ID=" (DataBinder.Eval(Container.DataItem, "Image"))  %>' ID="Img1"/>

Exception:
cannot convert from type byte() to type integer()



任何想法??


any ideas??

推荐答案

这是因为没有类型<$ C#中的c $ c> byte()或 integer(),在VB.NET中,它们可以是这些整数值的数组。



类型 byte int 和多很多。您需要的转换是通过分配完成的。这是因为类型 byte 的值集是 int 类型的子集。如果 int 变量到 byte 变量,你需要输入大小写来赋值。



对于不同数字类型的数组,根本不能分配它们。我是否需要解释如果可以进行此类演员会发生什么?



(我用更一般的术语来解释它的值,而不是范围,因为并非所有数字类型都有范围,浮点类型的工作方式不同,包括无穷大和非数字值。但是,它们有赋值兼容性规则。但整数类型有范围。范围是坏的,邋term的术语,它成为一种普遍使用的计算术语;值集的正确术语是域。)



另外, int byte 实际上是 System.Int32 的别名,System.Byte 。所有数字类型都有别名,以使代码独立于 System 命名空间。



请参阅:

http://msdn.microsoft.com /en-us/library/ae55hdtk%2​​8v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/ms173105.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/s2dy91zy.aspx [ ^ ],

http://www.fmsinc.com/free /NewTips/NET/NETtip6.asp [ ^ ]。



另请参阅此CodeProject文章:备忘单 - 使用VB.NET和C#进行投射 [ ^ ]。



该怎么办?查看在ASP.NET构造中使用的变量类型。



-SA
This is because there are not the types byte() or integer() in C#, and, in VB.NET, they can be the arrays of those integer values.

There are types byte, int and a lot more. "Conversion" you need is done by assignment. This is because the set of values if the type byte is a subset of that of the type int. You need type case to assign the value if int variable to byte variable.

As to arrays of different numeric types, they cannot be assigned compatible at all. Do I need to explain what would happen if such cast would be possible?

(I explained it in more general terms of sets of values, not ranges, because not all numeric types have ranges, floating-point types work differently and include Infinity and Not-a-Number values. Still, they have assignment compatibility rules. But integer types have ranges. "Range" is a bad, sloppy term which became a universally used computing jargon; correct term for set of values is "domain".)

Also, int and byte are actually alias names for System.Int32 and System.Byte. All numeric types have alias names, to make the code independent from the System namespace.

Please see:
http://msdn.microsoft.com/en-us/library/ae55hdtk%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms173105.aspx[^],
http://msdn.microsoft.com/en-us/library/s2dy91zy.aspx[^],
http://www.fmsinc.com/free/NewTips/NET/NETtip6.asp[^].

See also this CodeProject article: Cheat Sheet - Casting in VB.NET and C#[^].

What to do? Review the types of variables you use in your ASP.NET construct.

—SA


这篇关于无法从byte()类型转换为integer()类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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