Netferrets Online Blog, Internet Related Programming Solutions, Created in C# .net, VB .net, MS SQL Server Javascript, HTML and CSS. Proving sample solutions to problems found when creating web application solutions.
Showing posts with label info. Show all posts
Showing posts with label info. Show all posts
Thursday, 1 August 2013
Facebook locale information and cultureinfo to get country in .net
You will need this in your code behind:
using System.Globalization;
'en_GB' will be replace so .net can understand the format, this was from a dynamic type, but you can use just a string if you wish.
var country = CultureInfo.GetCultureInfo(locationinfo["locale"].Replace("_", "-")).EnglishName;
string countryName = country;
countryName = countryName.Substring(countryName.IndexOf("(") + 1, (countryName.Length - countryName.IndexOf("(")) - 2);
Instead of returning 'English (United Kingdom)' it will now return 'United Kingdom' only.
This has several uses, but I needed it to reference the city and country from facebook to a google map. I had the city information, but the main issue was getting a clean country name which is why this was needed because city names can appear in different countries.
I will probably go into further detail as some point as to what can be achieved with these.
Subscribe to:
Posts (Atom)