, , ( "" ) . , , , nines "#" .ToString(...).
, , -
string one = "(9?99) 999-9999";
string two = "2221239876";
StringBuilder sb = new StringBuilder();
int j = 0;
for (int i = 0; i < one.Length; i++)
{
switch (one[i])
{
case '9': sb.Append(two[j++]);
break;
case '?':
break;
default:
sb.Append(one[i]);
break;
}
}
Obviously, you should check to see if IndexOutOfRange exceptions occur if any row is โlongerโ than the other (that is, โoneโ contains more than nine than length โtwoโ, etc.)
source
share