A large percentage of my code generally comes from the internet simply because it's both a pain and unnecessary to re-write code that someone else has written and tested. The rest is from writing my own code and adjusting the samples I've found online to fit my purpose. Basically, google-fu
As has previously been said, I strongly advise you experiment. A lot. The best advice I can give you is to code, code and code. It's like learning a musical instrument. You only get better with practice. Make simple projects for yourself and write them. As you get better, you'll find yourself designing better code and reusing functions and classes you've written previously and even get to writing your own code library.
A good book always helps, I feel that "Programming C# 4.0" by Jesse Liberty et al. is an essential desktop purchase. Pretty much the core of the language is clearly explained part by part with a simple example to show you it in use. Jon Skeet's "C# in Depth - Second Edition" will help you better understand what is going on in your programs.
Finally, don't be afraid to experiment and ask for help if you get stuck. We all began somewhere and the majority of people will be keen to help if they can.