这样做经常需要添加类型强制转换来编译代码。
Doing so often necessitates the addition of casts to get the code to compile.
DB 2 9.7现在支持隐式的数据类型强制转换。
还有一种选择是,检查不变量以确保类型强制转换将会成功。
Alternatively, examine the invariants to ensure that the casts will succeed.
这种方法可除去上面代码中类型强制转换的需要,但不修正错误。
This approach would eliminate the need to cast in the above code, but it would not fix the bug.
当数字从一种类型强制转换为另一种类型时,通常会发生转换。
Conversion typically occurs when the number is cast from one type to another type.
治疗和预防措施:把类型强制转换代码分解到每个类的单独方法中去。
Cures and preventions: Factor the casting code out into separate methods for each class.
另一个例子,在调用宿主对象的函数时,如何进行类型强制转换,这也是没有规定的。
Another example is that it's not explained how types are coerced when calling functions on host objects. For example, when you do.
把类型强制转换当作一种断言,把不变量当做说明该断言为true的原因的参数。
Think of a cast as a kind of assertion and the invariants as arguments for why the assertion is true.
其次,它消除了易出错的类型强制转换的需要(这是一个在查询操作中比在CRUD中更常见的问题)。
Secondly, it removes the need for error-prone type casts. (a problem more common with query operations than CRUDs.)
一种解决方案是更改查询,将十进制类型强制转换为较小的数据类型,或者转换为字符串或二进制。
One solution would be to change the query to cast the decimal type to either a smaller datatype or convert to string or binary.
简言之,这些方法的本质总是使您确信代码块内部的不变量会确保代码块中的任何类型强制转换都将成功。
In short, the moral to this story is to always convince yourself that the invariants inside a code block ensure that any casts in the block will always succeed.
它进行静态类型检查,并且不允许强制类型转换,因而对于类型而言是安全的。
It is statically type-checked and does not allow type coercion, so is safe with regards to types.
用于弱类型变量,以将它们强制转换为另一种类型。
改变了类型强制规则,以保持数组(更为常见)中的类型 ,而不是转换为Python 标量的类型。
The type coercion rules have changed to preserve types in arrays (more often), rather than converting to the type of a Python scalar.
因此在决定如何对该方法的返回值进行强制类型转换时,必须同时考虑预期的返回类型和所用的数据模型。
One must therefore take into account both the expected return type and the data model when deciding how to cast the object that this method returns.
解决方案是将一个操作数强制转换成 64位的类型。
The solution is to cast one of the operands to its 64-bit type.
CAST函数被调用两次,以将输入参数的值(针对城市和州)强制转换适当的数据类型。
The cast function is called twice to cast the values of the input parameters (for city and state) to appropriate data types.
最后,可以根据列编号为这些列建立索引,并直接强制转换结果(对于某些类型)。
Finally, you can index into the columns by column number and cast the results directly (for some types).
比范围更加微妙的是指针和整型之间的转换;由于这些转换通常都包括强制类型转换,因此编译器很难告诉您到底做错了什么。
More subtle than ranges are conversions between pointers and integers; because these conversions generally involve casts, it's hard for the compiler to tell you what you're doing wrong.
换句话说,编译器生成的代码与您手工编写的不用泛型、检查程序的类型安全后进行强制类型转换所得到的代码基本相同。
In other words, the compiler generates pretty much the same code you would have written by hand without generics, casts and all, after checking the type-safety of your program.
毕竟,强制类型转换对于编译器来说就是一个提示,表明您清楚自己正在做些什么。
After all, casts are a hint to the compiler that you think you know what you're doing.
注意,在清单2中,从集合中提取项并不需要将其强制转换为正确的类型。
Notice in Listing 2 that fetching an item out of a collection doesn't require a cast to the right type.
比如泛型更改——泛型类型信息——由编译器用于实施编译时安全,但是生成的字节码仍然到处使用强制转换。
Likewise with the generics changes — the generic type information is used by the compiler to enforce compile-time safe usage, but the generated bytecode still USES casts everywhere.
这类规则被分成17个子类,这些子类关注于强制类型转换,可移植性以及反射等等。
The rules in this category are subdivided into 17 additional subcategories that allow you to confine your inspection to areas such as casting, portability, reflection, and so on.
读取一个参数值会耗费不少资源(因为类型的强制转换)。因此,缓存参数值是有意义的,至少当组件正在呈现自己时。
Reading a parameter value can be marginally expensive (because of type coercion). Therefore, it makes sense to cache the parameter value, at least while the component is actively rendering itself.
CriteriaQuery被传递给一个可执行查询并保留类型信息,这样可以直接访问选择列表的元素,而不需要任何运行时强制类型转换。
CriteriaQuery is transferred to an executable query with its type information preserved so that the elements of the selected list can be accessed without any run-time casting.
不幸的是,如果将来的API修订版允许将除jmenu类型之外的元素添加到JMenuBar,就不再需要把返回的元素强制转换JMenu了。
Unfortunately, if a future API revision lets you add elements of types other than JMenu to a JMenuBar, it will no longer be necessary, or even safe, to cast the returned elements to JMenu.
要从集合中提取元素,您必须知道集合中对象的类型,以将其强制转换为合适的局部变量。
To fetch elements from the collection, you had to know the type of object in the collection so you could cast it back to the appropriate local variable.
XMLCursor是泛型的,因此regionr =i.next()不需要强制转换,因为编绎器了解i 是 XMLCursor类型。
XMLCursor is generic, so the line region r = i.next() does not need a cast, since the compiler realizes that i is of type XMLCursor.
XMLCursor是泛型的,因此regionr =i.next()不需要强制转换,因为编绎器了解i 是 XMLCursor类型。
XMLCursor is generic, so the line region r = i.next() does not need a cast, since the compiler realizes that i is of type XMLCursor.
应用推荐