Archive for the ‘String Manipulation’ Category
How to Convert Arraylist to String using .Net
Posted by: admin in Array, String Manipulation, VB.Net on October 28th, 2009
-
Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList) As String
-
Return ArrayListToString(ar, ","C)
-
End Function
-
-
Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList, ByVal delim As Char) As String
-
Return ArrayListToString(ar, delim.ToString)
-
End Function
-
-
Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList, ByVal delim As String) As String
-
Return String.Join(delim, CType(ar.ToArray(GetType(String)), String()))
-
End Function
How to convert string to Hex
Posted by: admin in .NET, String Manipulation, VB.Net on September 8th, 2009
-
Function HexToDec(ByVal value As String) As Long
-
' we just need a call to the Convert.ToInt64 static method
-
Return Convert.ToInt64(value, 16)
-
End Function
How to Convert String to Date Format
Posted by: admin in .NET, C#, Date Formatting, String Manipulation, VB.Net on May 3rd, 2009
To Convert String To Date Format, use the DateTime.ParseExact function
DateTime.ParseExact(s as String, format as String, provider As IFormatProvider) as DateTime
Parameters:
- s
- Type: System.String
A string that contains a date and time to convert.
- format
- Type: System.String
A format specifier that defines the required format of s.
- provider
- Type: System.IFormatProvider
An object that supplies culture-specific format information about s.
Example:
-
Private Function ToDate() As DateTime
-
-
Dim str As String = "20060505"
-
-
Dim mDate As DateTime
-
-
-
-
mDate = DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat)
-
-
Return mDate
-
-
End Function
Read More about DateTime.ParseExact Method (String, String, IFormatProvider)
How to Clear StringBuilder
Posted by: admin in String Manipulation on April 20th, 2009
How to clear StringBuilder data;
Dim StrB as new StringBuilder
1. Way to clear is to set the Length to 0
-
StrB.Lenght = 0
2. Or reassign it
-
-
StrB = new StringBuilder