1

How do I transform this to C# 2.0 (without the use of lambda expression)?

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
    }
}
Community
  • 1
  • 1
FBN10040
  • 23
  • 3

1 Answers1

0

Use an Anonymous Method.

    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
        }
    }
Ryan T. Grimm
  • 1,307
  • 1
  • 9
  • 17