开发者

What are the differences between `ToXXXX` and `AsXXXX` conversion methods?

开发者 https://www.devze.com 2023-01-05 20:26 出处:网络
Is there any semantic difference between ToXXXX conversion methods and AsXXXX开发者_Go百科 conversion methods in the .NET framework?

Is there any semantic difference between ToXXXX conversion methods and AsXXXX开发者_Go百科 conversion methods in the .NET framework?

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号