CS mainly is something to practice I feel like.
I used to regualry jump into custom games alone, and simply practice CSing, this would clearly help me achieve higher CS in my games around that time.
The trick mainly is to just get every CS you can get in your lane, so if you go agressive in lane, you have to balance it so you still can CS while doing so. Same goes for playing passive, it pretty much just is practice how to get the most CS while doing so.
Roaming is a bit different, and when you can provide your sidelane good help, it is worth losing CS for it.
But generally there is one Basic rule with roaming, that says that you first should push out your lane. This makes it to where you get every minion that is in your lane shortly before you go roam, and when you come back, not as many minion were about to run into your turret and die without you being there to get them.
Latter is also the reason why you usually shouldn't roam when your enemy is present in lane and has decent waveclear/pushpotential, as they'd just push everything into your turret so you lose those CS.
I've had games where I and my enemy were at 50 CS around 15 mins, simply because we'd constantly be fighting around in junglers, or one would roam and the other follow. >.<