Namespace AdamSpeight2008
Public Module Testing
Public Sub Test()
REM A comment
Dim i As Integer = 42
' Also Comment
Dim s As String = " This ain't a comment"
End Sub
' Attribute
<Extension>
Public Function NonWhiteSpaceCount(s As String) As Integer
Return s.Where(Function(c) Not Char.IsWhiteSpace(c)).Count()
End Function
<Extension>
Function CountNonWhiteSpace_Linq(ByVal s As string) As Integer
Return Aggregate c In s
Where Not Char.IsWhiteSpace(c)
Into Count
End Function
Dim x As Xml.Linq.XElement = <TimeNode>
<Time Value=<%= Now.TimeOfDay %> ></Time>
</TimeNode>
Dim xt As String() = x.<Time>.Where(Function( xe) [email protected]="12:00.00").Select(Function(x) [email protected] ).ToArray
Public Function Test2() As String
Return "A Test String"
End Function
' XML Literal
Dim x2 = <test>
<node a1="1">
</node>
</test>
Public Sub Test3()
For i = 1 To 10
Console.WriteLine(i)
Next
For i = 10 To 1 Step -1
If i = 4 Then
Console.Write("Four:")
ElseIf i=5 Then
Console.Write("Five:")
Else
Console.Write("----:")
End If
Console.WriteLine(i)
Next i
For Each xx In {1,2,3,4,5}
Console.WriteLine(xx)
Next
Dim ii=0
While i < 10
Console.WriteLine("Hello World!")
i += 1
End While
Do
i = i - 1
Console.WriteLine("Do Loop Until Test")
Loop Until i =0
Do
i = i + 1
Console.WriteLine("Do Loop While Test")
Loop While i < 10
Dim ts = 10
Select Case ts
Case Is < 0 : Console.WriteLine("LessThan 0")
Case 0,1 : Console.WriteLine("Case 2")
Case 2 To 4: Console.WriteLine("Case 3")
Case Else
Console.WriteLine("Case Else")
End Select
End Sub
Public Iterator Function OneToTen() As IEnumerable(Of Integer)
For i = 1 To 10
Yield i
Next
End Function
Public Function TenToOne() As IEnumerable(Of Integer)
Return Iteration Function()
Dim i=10
While i>0
Yield i
i -= 1
End While
End Function
End Function
End Module
End Namespace
I think that covers most of the stuff
This post has been edited by AdamSpeight2008: 03 April 2013 - 08:29 AM
Reason for edit:: Helps if I spell the Keywords correctly. DOH!

New Topic/Question
This topic is locked



MultiQuote



|