extension method phone format with country code as parameter

Posted by frenchie on Stack Overflow See other posts from Stack Overflow or by frenchie
Published on 2011-01-18T03:40:24Z Indexed on 2011/01/18 3:53 UTC
Read the original article Hit count: 212

Filed under:

Hi,

I'm writing an extension method called ToPhoneFormat that formats a string of digits to phone numbers.

Is it possible to add a parameter to the method that would enable me to call it like this: MyPhoneString.ToPhoneFormat(international code)

That way, I could write MyPhoneString.ToPhoneFormat(1); to format a US phone number and MyPhoneString.ToPhoneFormat(33) to format a French phone number.

I already wrote the method that does the formatting but I'm wondering how to build the constructor so that it works with a parameter when I'm calling it.

Thanks.

© Stack Overflow or respective owner

Related posts about c#