PhoneNumberFormatter.TryCreate(String, PhoneNumberFormatter) PhoneNumberFormatter.TryCreate(String, PhoneNumberFormatter) PhoneNumberFormatter.TryCreate(String, PhoneNumberFormatter) PhoneNumberFormatter.TryCreate(String, PhoneNumberFormatter) PhoneNumberFormatter.TryCreate(String, PhoneNumberFormatter) Method

Definition

Attempts to create a PhoneNumberFormatter for a given region code, and doesn't throw on failure.

public : static void TryCreate(Platform::String regionCode, PhoneNumberFormatter phoneNumber)
static void TryCreate(winrt::hstring regionCode, PhoneNumberFormatter const& phoneNumber) const;
public static void TryCreate(String regionCode, PhoneNumberFormatter phoneNumber)
Public Shared Sub TryCreate(regionCode As String, phoneNumber As PhoneNumberFormatter)
Windows.Globalization.PhoneNumberFormatting.PhoneNumberFormatter.tryCreate(regionCode, phoneNumber);

Parameters

regionCode
String String String

The region code of the new PhoneNumberFormatter.

phoneNumber
PhoneNumberFormatter PhoneNumberFormatter PhoneNumberFormatter PhoneNumberFormatter PhoneNumberFormatter

On success, a new PhoneNumberFormatter for the requested region code.

On failure, this value is null.

Remarks

The following code snippet demonstrates how to use this method to create a PhoneNumberFormatter for the "BR" region.


    using Windows.Globalization.PhoneNumberFormatting;

    PhoneNumberFormatter currentFormatter = null;

    PhoneNumberFormatter.TryCreate("BR", out currentFormatter);
    if (currentFormatter != null)
    {
        // use the formatter 
    }  
    else
    {
        // formatter could not be created for the given region. 
        // put your fallback logic here.
    }