类型转换不起作用 [英] type cast won't work
问题描述
给出以下代码行。 。 。
System :: Collections :: Generic :: List< unsigned intls(1000);
String ^ datum =" 12345" ;;
如何将数据更改为无符号整数值并将其放入ls [0]?
我已经尝试过了。 。 。
ls [0] =(unsigned int)数据;
.. 。但编译器无法执行转换。
Daniel
Given the following lines of code . . .
System::Collections::Generic::List<unsigned intls(1000);
String^ datum = "12345";
How would I change datum into an unsigned integer value and put it in ls[0]?
I''ve already tried . . .
ls[0] = (unsigned int)datum;
.. . . but the compiler was not able to perform the coversion.
Daniel
推荐答案
嗨丹尼尔,
Hi Daniel,
给出以下代码行。 。 。
System :: Collections :: Generic :: List< unsigned intls(1000);
String ^ datum =" 12345" ;;
如何将数据更改为无符号整数值并将其放入
ls [0]?我已经尝试过了。 。 。
ls [0] =(unsigned int)数据;
Given the following lines of code . . .
System::Collections::Generic::List<unsigned intls(1000);
String^ datum = "12345";
How would I change datum into an unsigned integer value and put it in
ls[0]? I''ve already tried . . .
ls[0] = (unsigned int)datum;
ls [0] = System :: Convert :: ToUInt32(datum);
-
SvenC
ls[0] = System::Convert::ToUInt32(datum);
--
SvenC
这给了我一个未处理的异常错误。
Daniel
SvenC < Sv *** @ nospam.nospamwrote in message
news:C9 *************************** ******* @ microsof t.com ...
That gives me an unhandled exception error.
Daniel
"SvenC" <Sv***@nospam.nospamwrote in message
news:C9**********************************@microsof t.com...
嗨丹尼尔,
Hi Daniel,
>给出以下代码行。 。 。
系统::集合::通用::列表< unsigned intls(1000);
字符串^ datum =" 12345" ;;
我怎么用将数据更改为无符号整数值并将其放入
ls [0]?我已经尝试过了。 。 。
ls [0] =(unsigned int)数据;
>Given the following lines of code . . .
System::Collections::Generic::List<unsigned intls(1000);
String^ datum = "12345";
How would I change datum into an unsigned integer value and put it in
ls[0]? I''ve already tried . . .
ls[0] = (unsigned int)datum;
ls [0] = System :: Convert :: ToUInt32(datum);
-
SvenC
ls[0] = System::Convert::ToUInt32(datum);
--
SvenC
嗨丹尼尔,
Hi Daniel,
这给了我未处理的异常错误。
That gives me an unhandled exception error.
您是否试图找出问题所在?
它不是System :: Convert :: ToUInt32(datum)。
当元素0不存在时,你正在访问ls [0]。
请按照MSDN文档学习如何使用
.Net框架类。
从你的帖子我真的建议你坚持使用C#
,这样你就不会有错误的机会。使用.Net框架进行
程序时,使用C ++ / CLI绝对没有任何好处。
-
SvenC
Did you even try to figure out what the problem is?
It is not System::Convert::ToUInt32(datum).
You are accessing ls[0] when element 0 does not exist.
Please follow the MSDN documentation to learn how to use
the .Net framework classes.
From your posts I would really suggest you stick with C#
which gives you less opportunity for mistakes. When you
program with the .Net framework you have absolutely no
benefit in using C++/CLI.
--
SvenC
这篇关于类型转换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!