常量表达式的隐式转换不是在runtim执行的 [英] Constant expressions' implicit conversions not performed at runtim

查看:78
本文介绍了常量表达式的隐式转换不是在runtim执行的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




反汇编后面的表达式我注意到int和decimal之间的隐式转换

似乎是在运行时执行的。为什么?


TIA,

Axel Dahmen


无效主要()

{

十进制a = 1.2m,b;


b = a + 0;

}

解决方案

对不起使用错误的标题。原来的问题是:为什么编译时转换后不是



-------------

" Axel Dahmen"写道:





反汇编后面的表达式我注意到隐式转换

之间int和decimal似乎在运行时执行。为什么?


TIA,

Axel Dahmen


无效主要()

{

十进制a = 1.2m,b;


b = a + 0;

}




" Axel Dahmen" < ke ******** @ newsgroup.nospamwrote in message

news:6F ********************** ************ @ microsof t.com ...





void Main()

{

十进制a = 1.2m,b;


b = a + 0;

}



b = a + 0m;


Axel,

Decimal结构比整数复杂一点。

十进制结构有许多内部字段,允许它提供它所具有的准确性。此外,还有一些代码必须在执行隐式转换时由结构本身执行,而不能在编译时执行



希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- < a href =mailto:mv*@spam.guard.caspershouse.com> mv*@spam.guard.caspershouse.com

" Axel Dahmen" < ke ******** @ newsgroup.nospamwrote in message

news:7A ********************** ************ @ microsof t.com ...


对于使用错误的标题很抱歉。原来的问题是:为什么在编译时进行转换后不是




-------------

" Axel Dahmen"写道:


>

反汇编下面的表达式我注意到int和decimal之间的隐式转换似乎是在运行时执行。为什么?

TIA,
Axel Dahmen

无效主要()
{
十进制a = 1.2m,b;

b = a + 0;
}



Hi,

disassembling following expression I noticed that the implicit conversion
between int and decimal appears to be performed at runtime. Why?

TIA,
Axel Dahmen

void Main()
{
decimal a=1.2m, b;

b = a + 0;
}

解决方案

Sorry for using the wrong caption. Original question is: Why isn''t the
following conversion performed at compile time?
-------------
"Axel Dahmen" wrote:

Hi,

disassembling following expression I noticed that the implicit conversion
between int and decimal appears to be performed at runtime. Why?

TIA,
Axel Dahmen

void Main()
{
decimal a=1.2m, b;

b = a + 0;
}



"Axel Dahmen" <ke********@newsgroup.nospamwrote in message
news:6F**********************************@microsof t.com...

Hi,

void Main()
{
decimal a=1.2m, b;

b = a + 0;
}

b = a +0m;


Axel,

The Decimal structure is a bit more complex than an integer. The
Decimal structure has a number of internal fields that allow it to provide
the accuracy that it does. Also, there is code that has to be executed by
the structure itself when performing an implicit conversion, which can not
be executed at compile-time.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Axel Dahmen" <ke********@newsgroup.nospamwrote in message
news:7A**********************************@microsof t.com...

Sorry for using the wrong caption. Original question is: Why isn''t the
following conversion performed at compile time?
-------------
"Axel Dahmen" wrote:

>Hi,

disassembling following expression I noticed that the implicit conversion
between int and decimal appears to be performed at runtime. Why?

TIA,
Axel Dahmen

void Main()
{
decimal a=1.2m, b;

b = a + 0;
}



这篇关于常量表达式的隐式转换不是在runtim执行的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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