Imports System
Imports System.Collections.Generic
Public Class StringManager
Public Shared InfoSPC_SEX As String = Chr(243) 'ASCII code 243 = ¾ (three quarters, three-fourths )
Shared Sub New()
End Sub
''' </summary>
''' <param name="prefixText"></param>
''' <param name="count"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
If count = 0 Then
count = 10
End If
Dim random As New Random()
Dim items As New List(Of String)(count)
For i As Integer = 0 To count - 1
Dim c1 As Char = ChrW(random.Next(65, 90))
Dim c2 As Char = ChrW(random.Next(97, 122))
Dim c3 As Char = ChrW(random.Next(97, 122))
items.Add(prefixText + c1 + c2 + c3)
Next
Return items.ToArray()
End Function
''' <summary>
''' 123 --> 123, 132, 213, 231, 321, 312
''' </summary>
''' <param name="s"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetPermutations(ByVal s As String) As IEnumerable(Of String)
If (s.Length > 1) Then
Return (From ch In s From p In GetPermutations(s.Remove(s.IndexOf(ch), 1))
Select String.Format("{0}{1}", ch, p)) '.Distinct()
End If
Return New String() {s}
End Function
Public Shared Function DictionaryJoinValue(ByVal d As Dictionary(Of String, String)) As String
'Dim a As String = d.Select(Function(x) x.Key + "=" + x.Value).Aggregate(Function(s1, s2) s1 + ";" + s2)
Dim s As String = String.Join(",", d.Select(Function(x) x.Value))
'Dim removeDuplicate() As String = {"A", "A", "B", "C"}
'Dim r = removeDuplicate.Distinct()
Return s
End Function
End Class