Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C# Programming › Should you favour if statements over exceptions?

Should you favour if statements over exceptions?

Posts 1–5 of 5 · Page 1 of 1
Laslod
Laslod
Should you favour if statements over exceptions?
Say you have a class
Code:
Player
{
  private int turbosLeft;
  private car myCar;
  public void ActivateTurbo()
  {

  }
}
And there's a car that has a turboable variable

Code:
Car
{
  public bool turboAble = false;
}
Should you generate an exception for each seperate occasion? Ex.

Code:
 public void ActivateTurbo()
 {
   try{myCar.activateTurbo} 
   catch(NotTurboableException) { }
   catch(OutOfTurbosException) { }
 }
Or should you favour if-statements? Ex.

Code:
public void ActivateTurbo()
 { 
   if(!myCar.turboAble) { }
   else if(this.turbosLeft <= =) {}
 }
#1 · 13y ago
NLErwinZ
NLErwinZ
You always should try to avoid try/catch and exception throw's,
So the solution is quick and simple: if/else-statements it will be! =d
#2 · 13y ago
TR
TrollerCoaster
try/catch is good if the return value is abstract (can be any integer/string/etc); Otherwise, I would use if/else since it is faster and easier to check for errors. @Laslod
#3 · 13y ago
Laslod
Laslod
Quote Originally Posted by TrollerCoaster View Post
try/catch is good if the return value is abstract (can be any integer/string/etc); Otherwise, I would use if/else since it is faster and easier to check for errors. @Laslod
But what if you had a class within a class. Say :

Code:
class class1
class class2
And you wanted to operate the methods of class 2 through class 1 :

Code:
class1
{
public void DoSomething()
{
 class2.DoSomething();
}
}
Wouldn't you want to know if anything threw an exception in class 2? Since if you had if statements only in class 2, class 1 would have no way of knowing if an error occured.
#4 · 13y ago
LO
Lovroman
If you need better performance go with if.
If you need better exception handling go with try/catch.
Or combine both./me
#5 · 13y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • Why Should You Be VIP?Heres Why!!By xesoc in CrossFire Hacks & Cheats
    13Last post 17y ago
  • how should you use hacks ?By elysian_lov3 in Combat Arms Discussions
    14Last post 16y ago
  • Spec Ops the Line: Should you buy it?By Empire in General Gaming
    5Last post 14y ago
  • which laptop should you guys choose?By lolbie in General
    16Last post 15y ago
  • The reasons why I hate white people - and so should youBy michalejohan in Flaming & Rage
    98Last post 16y ago

Tags for this Thread

None