I was practicing to code anagram, but I find it easy since there is this method called Array.Sort().
Without using the method above, how do you sort them alphabetically? I just switched from Java to VB.net and still learning so yea :)
Assume this is the code:
Module Module1
Sub Main()
Dim str1, str2, str3 As String
Dim char1(), char2(), char3() As Char
Console.WriteLine("Enter 1st string:")
str1 = Console.ReadLine().ToLower.Replace(" ", "")
Console.WriteLine("Enter 1st string:")
str2 = Console.ReadLine().ToLower.Replace(" ", "")
Console.WriteLine("Enter 1st string:")
str3 = Console.ReadLine().ToLower.Replace(" ", "")
char1 = str1.ToCharArray()
char2 = str2.ToCharArray()
char3 = str3.ToCharArray()
End Sub End Module
If you can use Linq
, you can call the OrderBy()
extension on an array. Here's some examples in C#.
'orderby' in linq using a string array c#
You might do something like this:
Dim ordered As Char() = char1.OrderBy(Function(x) x).ToArray()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.