wrote:
> On Jan 16, 12:57*pm, nick_keighley_nos...@hotmail.com wrote:
>> On 16 Jan, 12:43, August Karlstrom <fusionf...@gmail.com> wrote:
>> > almu...@altavista.com wrote:
>> > > Hi
>>
>> > > Hope you can help me with this one. Is the following "C" code:
>>
>> > > short somevar, MethodName();
>>
>> > > shorthand for:
>>
>> > > short somevar = MethodName();
>>
>> > > where the MethodName() returns a short?
>>
>> > No, it's a shorthand for
>>
>> > short somevar;
>> > short MethodName();
>
> Just to let you know - i'm converting this C code into the
> equivalent C#.NET code. That's why I wanted the clarification as
> MethodName() returns a short so i think I have to do somethign like
> this in C#.NET:
>
> short somevar;
> short someVar = MethodName();
If your C source /really is/
short somevar, MethodName(); // A
then you /must not/ translate it into
short somevar = MethodName(); // B
because that would not have the correct effect. The effect of
(A) is to declare that `somevar` is a short variable and that
`MethodName` is a function taking an unspecified argument list
and returning a short; it /does not/ call `MethodName()`. The
C# form (B) is, offtopically and IIRC, a declaration of `shortvar`
and a /call/ to `MethodName()`, assigning the result of the
latter to the newly-declared variable.
[This is assuming that (A) isn't from C code so old that any
kind of literal translation, into C89, C99, C++, C#, or C-side,
would be more boneheaded than a shipful of Minbari.]
--
"- born in the lab under strict supervision -", /Genetesis/
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN