What is the benefit of having user defined return type over predefined datatype for a method in C#? [closed]

The benefit is that if you’ll ever want to change the return type, or return another value in addition to the one you’re already returning, you won’t have to change the code using the method.

It is a good practice, in general, a rule of thumb if you’d like. However, it is not very common in most project, and only become such when such a change is actually needed, and then refactoring is done.

The reason for that is that there is overhead to such design – too many classes and structures added to the project, and most of the time you can’t really tell when to reuse such a wrapping class in another method and when to create a new one.

Leave a Comment