Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在标签或web浏览器中显示web中的返回值_C#_Asp.net - Fatal编程技术网

C# 如何在标签或web浏览器中显示web中的返回值

C# 如何在标签或web浏览器中显示web中的返回值,c#,asp.net,C#,Asp.net,如何在标签或web浏览器中显示web中的返回值? 守则: public static string FormatTelephoneNumber(string value) { value = new System.Text.RegularExpressions.Regex(@"\D").Replace(value, string.Empty); value = value.TrimStart('1'); if ((!string.IsNullOrEmpty(value)

如何在标签或web浏览器中显示web中的返回值? 守则:

public static string FormatTelephoneNumber(string value)
{
    value = new System.Text.RegularExpressions.Regex(@"\D").Replace(value, string.Empty);
    value = value.TrimStart('1');

    if ((!string.IsNullOrEmpty(value)) && (value.Length >= 12))
        return Convert.ToInt64(value).ToString("{0:+234 ### ### ####}");
    if (value.Length == 10)
        return Convert.ToInt64(value).ToString("{0:+1 ### ### ####}");
    if (value.Length != 10)
        return Convert.ToInt64(value).ToString("0:+44 ###-###-#### " + new String('#', (value.Length - 10)));
    if (value.Length == 10)
        return Convert.ToInt64(value).ToString("{0:+233 ### ### ###}");

    return value;
}

假设这是一个Web表单项目(因为您没有在问题中提供任何详细信息)

代码隐藏(.aspx.cs)

页面(.aspx)



只需将其指定给标签的文本即可。如果您需要更多帮助,您应该解释您在问题中试图问什么,并解释您尝试了什么。

请提供模式详细信息。mvc或webforms是什么样的项目?你检查过文档了吗?我不确定问题出在哪里。它只适用于11位数字。如何测试它的10位和7位数字?@user3849239你应该单独问这个问题,因为这与当前的问题无关。
string input="5555555555";
MyLabel.Text = FormatTelephoneNumber(input);
<asp:Label runat="server" id="MyLabel" />