I'll assume you mean Bad Company 2. In that case, they're really quite different. Bad Company 2 is a first-person shooter, while inFamous is more of a third-person shooter where you fire lightning instead of bullets.
BC2 is rated M by the ESRB, while inFamous is rated T. inFamous runs about 20 hours with no multiplayer (which, in my view, would have ruined it anyway), whereas BC2 clocks in around 8 hours but includes multiplayer. That multiplayer is every bit as good as, or better than, Modern Warfare 2, just with fewer modes. Personally, I lean toward inFamous.