Wednesday, December 27, 2017

Conversion from array List / String Array to StringList in ASP.NET

Conversion from array List / String Array to StringList in ASP.NET

You can convert ArrayList to String list in convenient way whose code snippet is given below :

Code Snippet 1 :
  Dim arrLst As New ArrayList()
       
        arrLst.Add("aaa@aaa.com")
        arrLst.Add("bbb@bbb.com")
        arrLst.Add("ccc@ccc.com")

        Dim strFinal As String
        Dim strarr() As String
        strarr = arrLst.ToArray(Type.GetType("System.String"))
        strFinal = String.Join(",", strarr)
        Response.Write(strFinal)

Output :
aaa@aaa.com, bbb@bbb.com, ccc@ccc.com

Code Snippet 2 (String Array to String):
         
  Dim count As Int32 = 2
        Dim arrLst(count - 1) As String
        Dim strFinal As String
        
        arrLst(0) = "101"
        arrLst(1) = "102"

        strFinal = String.Join(",", arrLst)

        Response.Write(strFinal)

Output :
aaa@aaa.com, bbb@bbb.com, ccc@ccc.com

No comments:

Post a Comment