I have the following C# code. For reasons I won't go into, this is the required way of localising.
My problem is, I cannot for the life of me figure out what path is not returning a value. There are no other errors in the below code:
ResourceManager ResMain = new ResourceManager("TorrentSched.Main", typeof(Main).Assembly); /// <summary>Returns a localised string based on the Current UI Culture</summary> public string Str(string Name) { Boolean StringNotFound = false; switch(Thread.CurrentThread.CurrentUICulture.ToString()) { case "en-GB": switch(Name) { case "MinimizeToTray": return "Closing the program minimises it to the tray. To fully quit the program, right-click the icon in your tray and choose Exit."; default: StringNotFound = true; break; } break; default: StringNotFound = true; break; } if(StringNotFound) { StringNotFound = false; switch(Name) { case "AppName": return ResMain.GetString("$this.Text"); case "MinimizeToTray": return "Closing the program minimizes it to the tray. To fully quit the program, right-click the icon in your tray and choose Exit."; case "ReallyExit1": return "Do you really want to exit?"; case "ReallyExit2": return "Torrents will not be checked and downloaded until you launch the program again!"; default: return "String not found!"; } } }
}- edited.StringNotFoundwill always be true, so the if-block is not necessary, but it may very well confuse the code analysis.elsecondition. You don't need the if condition at all. The simple solution to this problem is have a single return outside of theifcondition. I suggest you post on the code review stack exchange website there several bad habits outlined in this code.