Posted December 11, 2007 and filed under    tags: 

While ignoring pressure from peer developers, I have chosen to stick with VB.NET as my development platform.  Almost everything I work on can be done with VB.NET, including converting those really handy C# code bits into VB.NET.  That being said, the other day I ran across a hand tip that will definitely make my life easier when writing code.  When writing a for loop statement I can nest the declaration in the For Next syntax.

For example, in the past I would write out a For Next statement like this:

Dim item as Object = Nothing 
For Each item in myObject 
...do something.. 
Next 

Now I would write it like this:

For Each item As Object In myObject 
    ...do something... 
Next 

I knew that C# can do this, but for some reason I never knew that VB.NET could also handle this syntax.

If you liked this article why not share it with others?

Kick it up to DotNetKicks.com

Add comment


(Will show your Gravatar icon)

biuquote
Loading