.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

VB.NET code to retrive only even numbers

Posted By:Hefin Dsouza       Posted Date: August 12, 2009    Points: 10    Category: LINQ    URL: http://www.dotnetspark.com  
 

This code sample uses Linq to get even numbers from an ArrayList of Numbers.
This Only works in VB 9.0 (VS.net 2008)

Sub GenEvenNumber(ByVal How_Many As Integer)
Dim a As New ArrayList()
For i As Integer = 1 To How_Many * 2
a.Add(i)
Next

Dim evenNumbers = From n In a Where n Mod 2 = 0 Select n
Console.WriteLine(How_Many & " Even Numbers Generated")
For Each enums As Integer In evenNumbers
Console.WriteLine("Even Number : " & enums)
Next
End Sub

Regards
Hefin Dsouza.


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend