Well, that's one way to do it



  • public ObservableCollection<MyType> MyTypeObservableList
     {
      get
      {
        var result = new ObservableCollection<MyType>();
        foreach (var myType in _myTypeList)
        {
          result.Add(myType );
        }
      return new ObservableCollection<MyType>(result);
      }
    }
    

    [mod - edited to put code into a backtick fence to render better, after being flagged - PJH]

    So it's creating an observable collection, adding everything in the list to it, then returning a new observable collection created with the observable collection he just created as the parameter.


  • Impossible Mission - B

    That's a very reasonable way to do it... if you're doing lazy initialization. But there doesn't seem to be any initialization and saving of the value here, so... undefined undefined



  • @campkev said in Well, that's one way to do it:

    adding everything in the list to it

    One by one!

    Yeah, there isn't a single thing here being done right...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.