How to get char array to string

raidstorm

New Member
Here is the code:<BR><BR>string GetSSNNumber()<BR>{<BR> //Grab SSN Number<BR> string strFinshedSSN = "";<BR> string strUnFormatedSSN = Request.Form["SSNPass"];<BR> char[] chrFormatedSSN = new char[11];<BR> strUnFormatedSSN.CopyTo(0, chrFormatedSSN, 0, 3);<BR> chrFormatedSSN[3] = '-';<BR> strUnFormatedSSN.CopyTo(3, chrFormatedSSN, 4, 2);<BR> chrFormatedSSN[6] = '-';<BR> strUnFormatedSSN.CopyTo(5, chrFormatedSSN, 7, 4);<BR> <BR> foreach ( char i in chrFormatedSSN ) <BR> {<BR> strFinshedSSN += chrFormatedSSN;<BR> }<BR> <BR> return strFinshedSSN;<BR>}<BR><BR>I am trying to format the SSN number and get a string back. any help? thanks.ToString() should work for all objects.<BR><BR>return strFinishedSSN.ToString();VB Example:<BR><BR>Dim teleArray() As String = {1,1,1,2,2,2,3,3,3,3}<BR>Dim TeleNum As String = Join(teleArray, "")<BR>TeleNum = "(" & Mid(TeleNum,1,3) & ") " & Mid(TeleNum,4,3) & "-" & Mid(TeleNum,7,4)<BR>Response.Write(TeleNum)<BR><BR><BR>Output: (111) 222-3333
 
Back
Top