|
Imports CumulativeHelper
Module MainModule
Sub Main()
' Array of test numbers
Dim numbers As Decimal() = New Decimal() {1, 3, 5, 7, 11}
' Calculate and print the cumulative sum for the numbers
System.Diagnostics.Debug.WriteLine("The cumulative sum contains the following results")
For Each partialSum As Decimal In numbers.CumulativeSum()
System.Diagnostics.Debug.WriteLine(" - {0}", partialSum)
Next
System.Diagnostics.Debug.WriteLine("The cumulative sum total is {0}", numbers.CumulativeSum().Last())
' Some random path
Dim somePath As String = "C:\Some directory\Some subdirectory\Somefile.txt"
' Split the path and print out each cumulated portion of the path
System.Diagnostics.Debug.WriteLine("The path contains the following parts")
For Each partialPath As String In somePath.Split("\").CumulativePath()
System.Diagnostics.Debug.WriteLine(" - '{0}'", New Object() {partialPath})
Next
' Some partially existing path
Dim somePath2 As String = "C:\Windows\Some non-existent directory\Some non-existent file.txt"
' Split the path and print out each cumulated portion of the path
System.Diagnostics.Debug.WriteLine("The path parts are valid as follows")
For Each partialPath As String In somePath2.Split("\").AllButLast().CumulativePath()
System.Diagnostics.Debug.WriteLine(" - '{0}' does exist: {1}", partialPath, System.IO.Directory.Exists(partialPath))
Next
End Sub
End Module
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.