VB.NET Sort DateTime Array using LINQ
Suppose String array as Dates in this format. DD-MMM-YYYY format.
Dim dtArra() As String = New String() {"12-jan-2001","12-feb-1973","7-Mar-1876","6-Dec-1967"}
If u want to sort using LINQ.
This is ascending order of dates.
var queryAsc = from d in dtArra
orderby
DateTime.ParseExact(d,
"%d-MMM-yyyy",
New System.Globalization.CultureInfo(1033))
Dim d As select
Dim str As String
For Each str In queryAsc
Console.WriteLine(str)
Next
Dates Ascending Order
6-Dec-1967
12-feb-1973
12-jan-2001
This is descending order of dates.
orderby
DateTime.ParseExact(d,
"%d-MMM-yyyy",
Shadows Property descending() As System.Globalization.CultureInfo(1033))
End Property
Dim d As select
Dim str As String
For Each str In queryDesc
Console.WriteLine(str)
Next
Dates descending Order
12-jan-2001
12-feb-1973
6-Dec-1967
7-Mar-1876
12-feb-1973
6-Dec-1967
7-Mar-1876
Tags:VB.NET Sort DateTime Array using LINQ,VB.NET Sort DateTime Array,dates Ascending order using LINQ,dates descending order using LINQ, Sorting DateTime Array Strings.LINQ Order by DateTime.ParaseExact
No comments:
Post a Comment