4

I am working with a c# application. If I access the

Thread.CurrentThread.CurrentCulture

object, and from inspection I find its culture is set to en-GB, how can I access the GB value? I looked at the object and it was not apparent where such was stored.

amateur
  • 43,371
  • 65
  • 192
  • 320

1 Answers1

5

Try in this way:

var name = Thread.CurrentThread.CurrentCulture.Name;
var locale = name.Split('-')[1];

Adapt the code above to check, in case, if the result of Split() returns an array with length equals to two. You can also use the Last() method from System.Linq to obtain the last element of it without having to relay on the index.

e_ne
  • 8,340
  • 32
  • 43