المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Prefix vs. Postfix Increments



C# Programming
04-12-2013, 11:30 PM
I've noticed I've been using a lot of prefix incrementors in code lately (esp. for counters), simple e.g.:

int counter = 0; foreach (var thing in things) { thingThatCares.TellMeWhereIAm(++counter); }
I typically don't see a lot of prefix operands in other folks' code, so I'm wondering if there's a better way of doing things like that, or it's just stylistic, etc.?