Lazy initialization

        static readonly object padlock = new object();
        private DataSet _dataSet;
 
        public DataSet DataSet
        {
            get
            {
                lock (padlock)
                {
                    if (_dataSet == null)
                    {
                        _dataSet = new ...;
                    }
                }
                return _dataSet;
            }
        }
programming/csharp/lazyinitialization.txt · Last modified: 2018-06-21 19:48 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0