473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# Equivalent to: For i = 30 To 32

I can't find any "short" code to make this work without taking 100s of
lines (because I have to keep repeating this process several times).
But this is what I have so far:

int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))

The VB.NET one is:
[code:1:c640d32a4b]
For i = 7 To 39
.SetValue(i & " 8", v)
v += 1
Next i[/code:1:c640d32a4b]
But I believe the C# code is way too big, is there any way to shorten
this?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #1
8 1396
Xucyr wrote:
But I believe the C# code is way too big, is there any way to shorten
this?


for (int i = 7; i <= 39; i++) {
// do your thing
}

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2
Użytkownik "Xucyr" napisał:
int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))


for (int i=7; i<=39; i++)
{
aryBadCoor.SetValue(i + " 25", v);
v++;
}

--
____ _
| _ \(_) ___ ___ _ _ piecu(at)go2.pl gg:1277308
| |_) | |/ _ \/ __| | | | --------------------------------
| __/| | __/ (__| |_| | "jutro to dzi¶ - tyle, że jutro"
|_| |_|\___|\___|\__,_| Sławomir Mrożek (1981)

Nov 15 '05 #3
I think VB is inclusive so I've used a <=, however, if it is not inclusive (32
isn't actually
processed) then change that to a simple <.

for(i = 30; i <= 32; i++) {
}
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Xucyr" <ni***@email-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
I can't find any "short" code to make this work without taking 100s of
lines (because I have to keep repeating this process several times).
But this is what I have so far:

int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))

The VB.NET one is:
[code:1:c640d32a4b]
For i = 7 To 39
.SetValue(i & " 8", v)
v += 1
Next i[/code:1:c640d32a4b]
But I believe the C# code is way too big, is there any way to shorten
this?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 15 '05 #4

"Xucyr" <ni***@email-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
I can't find any "short" code to make this work without taking 100s of
lines (because I have to keep repeating this process several times).
But this is what I have so far:

int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))

The VB.NET one is:
[code:1:c640d32a4b]
For i = 7 To 39
.SetValue(i & " 8", v)
v += 1
Next i[/code:1:c640d32a4b]
But I believe the C# code is way too big, is there any way to shorten
this?

The C# equivalent is:

for(int i = 7; i <39; i++)
{
// Put your C# equivalent code for what you
// are trying to do here
}

This is counter-controlled repetition in C#.
The three expressions in the () following the for are:
1. The initializer - declares and initializes the loop control variable
2. The continuation test - as long as i is < 39, the loop continues. When i
is no longer < 39, the loop terminates.
3. The modifier - changes the value of the loop control variable at the end
of each pass through the loop. In my example, add 1 to i each time.
To understand the for loop, you need to know what happens when:
1. Execute the initializer (*only* the first time)
2. Execute the test. If the expression is true, execute the controlled code
block.
3. modify the loop control variable according to the modifier expression.
4. Go back to 2. above
5. If 2. results in false, exit to the code following the controlled block

--
Peter [MVP Academic]
Nov 15 '05 #5
Holy cow you guys are good =)

Thank you!
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #6

"Xucyr" <ni***@email-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
I can't find any "short" code to make this work without taking 100s of
lines (because I have to keep repeating this process several times).
But this is what I have so far:

int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))

The VB.NET one is:
[code:1:c640d32a4b]
For i = 7 To 39
.SetValue(i & " 8", v)
v += 1
Next i[/code:1:c640d32a4b]
But I believe the C# code is way too big, is there any way to shorten
this?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

The C# equivalent is:

for(int i = 7; i <39; i++)
{
// Put your C# equivalent code for what you
// are trying to do here
}

This is counter-controlled repetition in C#.
The three expressions in the () following the for are:
1. The initializer - declares and initializes the loop control variable
2. The continuation test - as long as i is < 39, the loop continues. When i
is no longer < 39, the loop terminates.
3. The modifier - changes the value of the loop control variable at the end
of each pass through the loop. In my example, add 1 to i each time.
To understand the for loop, you need to know what happens when:
1. Execute the initializer (*only* the first time)
2. Execute the test. If the expression is true, execute the controlled code
block.
3. modify the loop control variable according to the modifier expression.
4. Go back to 2. above
5. If 2. results in false, exit to the code following the controlled block

--
Peter [MVP Academic]

Nov 15 '05 #7

If you're looking for a fast way to convert VB.NET syntax to C#, you can
check out my book, "The .NET Languages: A Quick Translation Guide". It has
translation tables that show the syntax equivalent for the entire VB.NET and
C# language.

Brian Bischof
--
http://www.amazon.com/exec/obidos/ASIN/1893115488

"Peter van der Goes" <p_**********@toadstool.u> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...

"Xucyr" <ni***@email-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
I can't find any "short" code to make this work without taking 100s of
lines (because I have to keep repeating this process several times).
But this is what I have so far:

int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))

The VB.NET one is:
[code:1:c640d32a4b]
For i = 7 To 39
.SetValue(i & " 8", v)
v += 1
Next i[/code:1:c640d32a4b]
But I believe the C# code is way too big, is there any way to shorten
this?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com The C# equivalent is:

for(int i = 7; i <39; i++)
{
// Put your C# equivalent code for what you
// are trying to do here
}

This is counter-controlled repetition in C#.
The three expressions in the () following the for are:
1. The initializer - declares and initializes the loop control variable
2. The continuation test - as long as i is < 39, the loop continues. When

i is no longer < 39, the loop terminates.
3. The modifier - changes the value of the loop control variable at the end of each pass through the loop. In my example, add 1 to i each time.
To understand the for loop, you need to know what happens when:
1. Execute the initializer (*only* the first time)
2. Execute the test. If the expression is true, execute the controlled code block.
3. modify the loop control variable according to the modifier expression.
4. Go back to 2. above
5. If 2. results in false, exit to the code following the controlled block

--
Peter [MVP Academic]

Nov 15 '05 #8
in c# you use

for(int i = 7; i <=39; i++)
{
....
}

hope this helps

Fitim Skenderi
"Peter van der Goes" <p_**********@toadstool.u> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...

"Xucyr" <ni***@email-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
I can't find any "short" code to make this work without taking 100s of
lines (because I have to keep repeating this process several times).
But this is what I have so far:

int i = 7;

do
{
aryBadCoor.SetValue(i + " 25", v);
v++;
i++;
} while (!(i ==39))

The VB.NET one is:
[code:1:c640d32a4b]
For i = 7 To 39
.SetValue(i & " 8", v)
v += 1
Next i[/code:1:c640d32a4b]
But I believe the C# code is way too big, is there any way to shorten
this?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com The C# equivalent is:

for(int i = 7; i <39; i++)
{
// Put your C# equivalent code for what you
// are trying to do here
}

This is counter-controlled repetition in C#.
The three expressions in the () following the for are:
1. The initializer - declares and initializes the loop control variable
2. The continuation test - as long as i is < 39, the loop continues. When

i is no longer < 39, the loop terminates.
3. The modifier - changes the value of the loop control variable at the end of each pass through the loop. In my example, add 1 to i each time.
To understand the for loop, you need to know what happens when:
1. Execute the initializer (*only* the first time)
2. Execute the test. If the expression is true, execute the controlled code block.
3. modify the loop control variable according to the modifier expression.
4. Go back to 2. above
5. If 2. results in false, exit to the code following the controlled block

--
Peter [MVP Academic]

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
3
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
1
by: Vannela | last post by:
Is there any equivalent control in .NET for the Power builder DataWindow control? I am explaining the Datawindow architecture to some extent. Power Builder DataWindow Control has got different...
6
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The...
3
by: Marty | last post by:
Hi, What is the VB.NET equivalent of the VB6 ADODB.Connector and ADODB.Recordset? Thanks Marty
7
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
10
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.