sriraag wrote:
when should i use managed code and when should i use the unmanaged one.

Use managed code unless you know you shouldn't, or can't.

For someone just getting started, which is what I'm sensing from you (no offense if that's not the case), "unmanaged code" shouldn't even be in your vocabulary at this point.