1
我是C#的新手,并且正在处理文本格式。我稍微离开了课程计划以格式化用户输入的电话号码。虽然程序编译并运行,但输入内容时会崩溃。C#ReadLine转换问题
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Strings
{
class Program
{
static void Main(string[] args)
{
int PhoneNumber = Convert.ToInt32(Console.ReadLine());
string myString = string.Format("Phone Number: {0:(###) ###-####}", PhoneNumber);
Console.WriteLine(myString);
Console.ReadLine();
}
}
}
感谢您的帮助。事情是:我最初尝试使用这个字符串,但它不会使用格式。我假设只有格式类型除了整数? – Mbdelta 2014-10-04 05:03:24