如何将其转换为C#2.0(不使用lambda表达式)?
How to get current regional settings in C#?
class Program
{
private class State
{
public CultureInfo Result { get; set; }
}
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture.ClearCachedData();
var thread = new Thread(
s => ((State)s).Result = Thread.CurrentThread.CurrentCulture);
var state = new State();
thread.Start(state);
thread.Join();
var culture = state.Result;
// Do something with the culture
}
}
答案 0 :(得分:0)
class Program
{
private class State
{
public CultureInfo Result { get; set; }
}
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture.ClearCachedData();
Thread thread = new Thread(delegate(object s)
{
((State) s).Result = Thread.CurrentThread.CurrentCulture;
});
State state = new State();
thread.Start(state);
thread.Join();
CultureInfo culture = state.Result;
// Do something with the culture
}
}