
Since C# supports overloading, the wrapper provides overloads so you don't have to specify the optional arguments.Īnother thing you'd use a wrapper for is if you want to access an object through an interface that the class doesn't implement.

The Windows API functions also have a lot of optional parameters, but, since they were written in C, which doesn't have function overloading, you have to manually put in null or some default value for all of the optional arguments every time. The File class wraps those functions and checks the error code for you, converting it into an exception. The functions that are part of the Windows API that operate on files, for example, require you to manually check an error code if something goes wrong. There are a couple big reasons to have a wrapper. The point of a wrapper is so you can use a different interface to access something. A wrapper is a class or function whose main purpose is to just forward calls to another class or function.
