Re: Postfix increment
- From: "Pete Davis" <pdavis68@[nospam]hotmail.com>
- Date: Fri, 23 Sep 2005 10:27:30 -0500
>
> "Oleg Kharitonov" <kh_oleg@xxxxxxx> wrote in message
> news:ORAKrlBwFHA.664@xxxxxxxxxxxxxxxxxxxxxxx
>> Hello!
>>
>> I have found an interesting thing with postfix operator ++.
>>
>> What should contain the variable i after exceution the following code:
>>
>> int i = 5;
>> i = i++;
>>
>> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
>> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>>
>> Is it behaviour correct? Can anyone explain what is the correct result?
>>
>> Best regards,
>> Oleg.
>
> The correct behavior is for the compiler to wipe out your harddrive and
> call you names, so as to prevent you from writing any code that bad again.
> :^)
>
> In C/C++ the behavior of
> [ i = i++ ; ]
> is undefined.
>
> I have not found anywhere in the C# standard where they discuss sequence
> points yet.
> So it is possible that this behavior is "Defined" in C#.
>
> It should, however, be avoided at all costs
>
> Bill
It's clearly defined in the C# standard. There's no reason to avoid it. If
it is undefined in C++, then it should be avoided in C++.
Pete
.
- Prev by Date: Re: RowFilters with related tables
- Next by Date: Re: Reading rows and columns from a DataGrid
- Previous by thread: Re: Postfix increment
- Next by thread: Re: Postfix increment
- Index(es):
Relevant Pages
|