I found some examples on the internet (this one I understand the most). I am confused on how to implement it. I do not know which assemblies I need to reference. Also, shouldn't I use classes from SharePoint's API? I am using SharePoint 2010. Thanks.
The example you provided by the link does use the Sharepoint API (using Microsoft.Office.Server; using Microsoft.SharePoint;using Microsoft.Office.Server.UserProfiles;). In order to be able to use those namespaces, you need to reference Microsoft.Sharepoint.dll, Microsoft.Office.Server.dll and Microsoft.Office.Server.UserProfiles.dll. I suggest you start with a console application (don't forget to set its platform target to Any CPU), add the above references and take portions of the code from your link and try out how it works. It's the fastest way to get familiar with something new.
If you can't find the dll's above on your server, it means you have Sharepoint Foundation. You need Sharepoint Server 2010 to use the UserProfiles.
I hope it helped.
UPS by default will pull the user's manager into the profile as long as there's good manager data in Active Directory; so it's likely that UPS is already setup with that unless someone in your organization changed the UPS configuration. Unfortunately, in a lot of environments that data is either not present, or wrong, so you may want to confirm (before you start relying on it) that there is good, solid manager data in Active Directory before you go down this path. I can't tell you how many people I've talked to that can't figure out why their code doesn't work, only to then discover that AD has no manager data.
For what it's worth, if you were using the manager lookup capabilities of a SPD workflow, that works in the same way (at a high level) as the example you've posted. The workflow will grab the current user's profile data, lookup the manager, then resolve the manager's profile.