更新时间:2023-02-18 08:17:45
mypetrock schrieb:
mypetrock schrieb:
Foo。条形数据=(For.Bar)输入[数据];
Foo.Bar data = (For.Bar)input["Data"];
''Cos Foo.Bar不是For.Bar。
开个玩笑
如果您编码会发生什么情况
if(输入["数据]]是Foo.Bar)
{
System.Diagnostics.Writeline(应该是可投递的);
}
其他
{
System.Diagnostics.Writeline(typeof(Foo.Bar).FullN ame);
System.Diagnostics.Writeline((input [" Data"])。GetType()。FullName);
}
?
''Cos Foo.Bar is not For.Bar.
Just kidding
What happens if you code
if(input["Data"] is Foo.Bar)
{
System.Diagnostics.Writeline("Should be castable");
}
else
{
System.Diagnostics.Writeline(typeof(Foo.Bar).FullN ame);
System.Diagnostics.Writeline((input["Data"]).GetType().FullName);
}
?
" mypetrock" < my ******* @ yahoo.comwrote:
"mypetrock" <my*******@yahoo.comwrote:
有没有人遇到过这条错误消息?
无法将''Foo.Bar'类型的对象强制转换为''Foo.Bar''。
我正在尝试转换类型为Foo.Bar的对象我从一个散列的
表中得到了一个Foo.Bar类型的变量。
Foo.Bar data =(For.Bar)输入[" ;数据"];
Has anyone run into this error message?
Unable to cast object of type ''Foo.Bar'' to type ''Foo.Bar''.
I''m trying to cast an object of type Foo.Bar that I got out of a hash
table into a variable of type Foo.Bar.
Foo.Bar data = (For.Bar)input["Data"];
你可能在不同的程序集中有两个不同的Foo.Bar'。也许
你们两个都包含相同的源代码文件?
- Barry
-
http://barrkel.blogspot.com/
" Barry Kelly" < ba *********** @ gmail.com写信息
新闻:bd ******************* ************* @ 4ax.com ...
"Barry Kelly" <ba***********@gmail.comwrote in message
news:bd********************************@4ax.com...
" mypetrock" < my ******* @ yahoo.comwrote:
"mypetrock" <my*******@yahoo.comwrote:
>有没有人遇到此错误消息?
无法使用将''Foo.Bar'类型的对象强制转换为''Foo.Bar''。
我正在尝试构建一个Foo.Bar类型的对象,我从将表格转换为Foo.Bar类型的变量。
Foo.Bar data =(For.Bar)input [" Data];
>Has anyone run into this error message?
Unable to cast object of type ''Foo.Bar'' to type ''Foo.Bar''.
I''m trying to cast an object of type Foo.Bar that I got out of a hash
table into a variable of type Foo.Bar.
Foo.Bar data = (For.Bar)input["Data"];
您可能在不同的程序集中有两个不同的Foo.Bar'。也许
你们两个都包含相同的源代码文件?
You may have two different Foo.Bar''s in different assemblies. Perhaps
you have the same source code file included in both?
或者GAC中的并排程序集,或者多个程序集.LoadFrom?
David
Or side-by-side assemblies in the GAC, or multiple Assembly.LoadFrom?
David