In C# and VB.Net a Select Case against a variable set to Nothing will not throw an exception; watch out. Check out the following code.
| Select Case processType Case "I" ' Move from FTP to working dir .ProcessType = FileMoverLib.FileMove.ProcessTypeMoveFromFTP Case "O" ' move from working folder to FTP .ProcessType = FileMove.ProcessTypeMoveToFTP Case Else Throw New Exception("processType not set in ProcessOneMoverObject") End Select |
| static void Main(string[] args) { string s3 = null; switch (s3) { case "a": // do something break; default: Console.WriteLine("Control should not get here."); break; } This is another simple tip but it could save you some headaches. Have you tried our newest product, Visual Class Organizer? You'll be amazed how easy it is to keep the code in your code windows organized. TRY IT FREE FOR 30 DAYS BY CLICKING HERE.If you are developing in C# and haven't tried CSharpCompleter, you are wasting valuable time typing hundreds of braces {} daily needlessly. Try CSharpCompleter for 30 DAYS FREE.
|