title: Type casting Collections using Conversion Operators
body: <p>The below code gives me User-defined conversion must convert to or from enclosing type, while snippet #2 doesn't...  It seems that <a href="http://msdn.microsoft.com/en-us/library/2x7fay24(VS.80).aspx" rel="nofollow noreferrer">a user-defined conversion routine must convert to or from the class that contains the routine.</a>  </p>
  
  <p>What are my alternatives?  Explicit operator as extension method?  Anything else?</p>
  
  <pre><code>public static explicit operator ObservableCollection&lt;ViewModel&gt;(ObservableCollection&lt;Model&gt; modelCollection)
  {
      var viewModelCollection = new ObservableCollection&lt;ViewModel&gt;();
  
      foreach (var model in modelCollection)
      {
          viewModelCollection.Add(new ViewModel() { Model = model });
      }
  
      return viewModelCollection;
  }
  </code></pre>
  
  <p>Snippet #2</p>
  
  <pre><code>public static explicit operator ViewModel(Model model)
  {
      return new ViewModel() {Model = model};
  }
  </code></pre>
  
  <p>Thanks in advance!</p>