0
char[] delimiterChars = {'-'};
string text = "123-45-6789"
string[] words = text.Split(delimiterChars);
foreach (string s in words)
{
  pdfFormFields.SetField("PutItHere: ", s);
}//foreach


Result: 
PutItHere: 6789

I want it to be like "123456789" , I dont know how to manipulate and put it like that. Pls help.

Amedee Van Gasse
  • 6,088
  • 3
  • 41
  • 73
Ping
  • 51
  • 6

2 Answers2

5

I think you should have used Replace instead

string text = "123-45-6789";
text = text.Replace("-", String.Empty);
Mohit Shrivastava
  • 12,996
  • 5
  • 31
  • 61
0

Any particular reason you want to use Split()?

If you have to use Split and put into a loop, you have to create a variable and concat each splitted string as the end result.

Also, pdfFormFields.SetField() need to put outside the loop. Otherwise the result will be replaced in each loop.

string result = string.Empty;
foreach (string s in words)
{
  result += s;
}//foreach
pdfFormFields.SetField("PutItHere: ", result);
Koo SengSeng
  • 773
  • 2
  • 8
  • 25