Reputation: 84835
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>
.
Upvotes: 10
Views: 2910
Reputation: 10658
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.
Upvotes: 16