简体   繁体   中英

format property in class to return phone number

Is it possible to format what I have below to return a phone number?

private string _Phone;
    [DataMember]
    public string Value
    {
        get { return String.Format("{0:(###) ###-####}", Int64.Parse(_Phone)); }
        set { _Phone = value; }
    }

如果先将字符串转换为long,则可以使用String.Format。

String.Format("{0:(###) ###-####}", Int64.Parse("8005551212"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM