views:

60

answers:

1
  1. Is there any semantic difference between ToXXXX conversion methods and AsXXXX conversion methods in the .NET framework?

    Examples of such methods are Object.ToString and Enumerable.AsEnumerable<T>.

  2. If no: Are there still recommendations when to name a conversion method AsXXXX and when to name it ToXXXX?

    If yes: Is there a .NET framework design guideline / FxCop style rule for this?

+12  A: 

If method returns the same instance but casted to another type, use AsXXX method. If method consntructs new instance of unrelated type using object data, use ToXXX method.

STO
The same thing has been mentioned in the book "Linq in Action".
devcoder