Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

C# to vb .net (2005) help

help me to convert the following c# code in vb .net (2.0)

do {
while (bl_counts[--incrBitLen] == 0);
do {
bl_counts[incrBitLen]--;
bl_counts[++incrBitLen]++;
overflow -= 1 << (maxLength - 1 - incrBitLen);
}
while (overflow > 0 && incrBitLen < maxLength - 1);
}

what is the meaning of while loop without curly braces in c#

awaiting reply.

Thanks
Javfarary
[440 byte] By [Javfarary] at [2007-11-11 10:03:44]
# 1 Re: C# to vb .net (2005) help
As I mentioned in another forum, the code you posted won't compile - your outer 'do' loop needs some condition (you can't have a conditionless 'do' loop in C#).

Here is an attempt to format your code to determine where your problem lies:

do //this 'do' loop needs a condition (either here or at the end)
{
//this is an empty while loop (perfectly legit):
while (bl_counts[--incrBitLen] == 0);

do
{
bl_counts[incrBitLen]--;
bl_counts[++incrBitLen]++;
overflow -= 1 << (maxLength - 1 - incrBitLen);
} while (overflow > 0 && incrBitLen < maxLength - 1);
//syntax error - you cannot close a simple 'do' loop like this in C#:
}

Regarding the loop without braces, it's just a loop that only executes 'header' logic under the condition is met.
David Anton at 2007-11-11 21:45:06 >
# 2 Re: C# to vb .net (2005) help
Thanks for the help, I got the while loop working in vb now. thanks

and what about this code...

if (windowFilled++ == WindowSize)
{
throw new InvalidOperationException("Window full");
}

if the condition is true then only windowFilled++?
Please convert it to vb.

Thanks
Javfarary
Javfarary at 2007-11-11 21:46:01 >
# 3 Re: C# to vb .net (2005) help
'windowFilled' is incremented after the conditional test, regardless of whether the test is true or false.
David Anton at 2007-11-11 21:47:00 >
# 4 Re: C# to vb .net (2005) help
OK. Thanks for the help.
Javfarary at 2007-11-11 21:48:00 >