The code you posted should not be causing you any problems. I ran the same sample code from our .NET examples on my local machine with my Username and Password without any issues. A 401 Unauthorized error would only be returned if one of the three errors below happens:
1. You have the incorrect username
2. You have the incorrect password
3. You have an invalid/disabled API key
Without having your actual values for these three items, I will not be able to replicate your 401 error. The easiest way to confirm that it is one of these items it to use a Browser or REST Client to do a request on your account. If it is your UN/PW/API Key, you will see the 401 error message in the browser or REST Client as well.
... View more