Bug or Feature in C# sourcecode?

T

Thomas Lehmann

Dear all,

I am debugging a very complicated C# program, based on .NET 2.0. The
author was a real C# expert, which I am still not.

I saw something strange and try to find out, if this is a bug or maybe a
C# feature. It is part of a property:


set
{
fData[iOffset + iIndex * + iStepSize] = value;
}


The part "* +" seems to be a bug for me, or does this exist?


Thank you for your answers,
Thomas
 
A

Alberto Poblacion

Thomas Lehmann said:
I am debugging a very complicated C# program, based on .NET 2.0. The
author was a real C# expert, which I am still not.

I saw something strange and try to find out, if this is a bug or maybe a
C# feature. It is part of a property:


set
{
fData[iOffset + iIndex * + iStepSize] = value;
}


The part "* +" seems to be a bug for me, or does this exist?


I believe that what the author probably meant was
iOffset+iIndex*iStepSize. However, there is a "unary +" operator, so
iIndex*+iStepSize would compile and yieled the same result as
iIndex*iStepSize (or in other words, the same value but with different sign
as iIndex*-iStepSize).
 
C

Cowboy \(Gregory A. Beamer\)

Thomas Lehmann said:
Dear all,

I am debugging a very complicated C# program, based on .NET 2.0. The
author was a real C# expert, which I am still not.

I saw something strange and try to find out, if this is a bug or maybe a
C# feature. It is part of a property:


set
{
fData[iOffset + iIndex * + iStepSize] = value;
}


The part "* +" seems to be a bug for me, or does this exist?

It is not advanced, complex code. It is merely an example of bad syntax to
get to a particular item in some sort of array or dictionary.

--
Gregory A. Beamer
MCP: +I, SE, SD, DBA

*********************************************
| Think outside the box!
|
*********************************************
 
I

Ignacio Machin ( .NET/ C# MVP )

Dear all,

I am debugging a very complicated C# program, based on .NET 2.0. The
author was a real C# expert, which I am still not.

I saw something strange and try to find out, if this is a bug or maybe a
C# feature. It is part of a property:

set
        {
        fData[iOffset + iIndex * + iStepSize] = value;
        }

The part "* +" seems to be a bug for me, or does this exist?

Thank you for your answers,
Thomas

Hi,

Weird yes, illegal no, the "+" is doing nothing there. Why this
"expert" did it like that is anybody guess.
Maybe it's a bug anyways :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top