Google.Api.Ads.AdWords.Examples.CSharp.v201306.GetTargetableLanguagesAndCarriers.Run C# (CSharp) Method

Run() public method

Runs the code example.
public Run ( Google.Api.Ads.AdWords.Lib.AdWordsUser user ) : void
user Google.Api.Ads.AdWords.Lib.AdWordsUser The AdWords user.
return void
        public void Run(AdWordsUser user)
        {
            // Get the ConstantDataService.
              ConstantDataService constantDataService = (ConstantDataService) user.GetService(
              AdWordsService.v201306.ConstantDataService);

              try {
            // Get all carriers.
            Carrier[] carriers = constantDataService.getCarrierCriterion();

            // Display the results.
            if (carriers != null) {
              foreach (Carrier carrier in carriers) {
            Console.WriteLine("Carrier name is '{0}', ID is {1} and country code is '{2}'.",
                carrier.name, carrier.id, carrier.countryCode);
              }
            } else {
              Console.WriteLine("No carriers were retrieved.");
            }

            // Get all languages.
            Language[] languages = constantDataService.getLanguageCriterion();

            // Display the results.
            if (languages != null) {
              foreach (Language language in languages) {
            Console.WriteLine("Language name is '{0}', ID is {1} and code is '{2}'.",
                language.name, language.id, language.code);
              }
            } else {
              Console.WriteLine("No languages were found.");
            }
              } catch (Exception ex) {
            throw new System.ApplicationException("Failed to get targetable carriers and languages.",
            ex);
              }
        }

Usage Example

 /// <summary>
 /// Main method, to run this code example as a standalone application.
 /// </summary>
 /// <param name="args">The command line arguments.</param>
 public static void Main(string[] args)
 {
     GetTargetableLanguagesAndCarriers codeExample = new GetTargetableLanguagesAndCarriers();
       Console.WriteLine(codeExample.Description);
       try {
     codeExample.Run(new AdWordsUser());
       } catch (Exception ex) {
     Console.WriteLine("An exception occurred while running this code example. {0}",
     ExampleUtilities.FormatException(ex));
       }
 }
GetTargetableLanguagesAndCarriers