The CInt
conversion function is also VB6-ish; in .NET you convert things, so instead of this:
CInt(readResult(i))
You would have that:
Convert.ToInt32(readResult(i))
Although, that's just one of many ways to convert types in VB.NET.
Lastly, idiomatic .net code will always have Option Explicit
and Option Strict
turned on.
What about LINQ?
As mentioned above, an array is an object. But it's not just any object - it implements an interface called IEnumerable
, which means the LINQ extension methods can be used to iterate it, instead of an explicit For
loop:
Dim readResult As String() = File.ReadAllLines(inputFile)
Dim multipliedResults = From line In readResults
Select MultiplyEvenNumbers(Convert.ToInt32(line))
But you'll probably want to learn a bit about closures and delegates before diving into this.