Click here to Skip to main content
15,887,355 members
Home / Discussions / C#
   

C#

 
AnswerRe: Error 'not all code paths return a value' Pin
Pete O'Hanlon22-Sep-17 12:08
mvePete O'Hanlon22-Sep-17 12:08 
GeneralRe: Error 'not all code paths return a value' Pin
BenScharbach14-Oct-17 9:11
BenScharbach14-Oct-17 9:11 
AnswerRe: Error 'not all code paths return a value' Pin
Karthik_Mahalingam25-Sep-17 19:55
professionalKarthik_Mahalingam25-Sep-17 19:55 
SuggestionRe: Error 'not all code paths return a value' Pin
Richard Deeming26-Sep-17 0:55
mveRichard Deeming26-Sep-17 0:55 
GeneralRe: Error 'not all code paths return a value' Pin
Karthik_Mahalingam26-Sep-17 1:12
professionalKarthik_Mahalingam26-Sep-17 1:12 
GeneralRe: Error 'not all code paths return a value' Pin
Richard Deeming26-Sep-17 1:14
mveRichard Deeming26-Sep-17 1:14 
GeneralRe: Error 'not all code paths return a value' Pin
Karthik_Mahalingam26-Sep-17 1:21
professionalKarthik_Mahalingam26-Sep-17 1:21 
AnswerRe: Error 'not all code paths return a value' Pin
Paul_Williams19-Oct-17 4:54
Paul_Williams19-Oct-17 4:54 
In your example there would be nothing to return if value where not one of the handled cases. You need to specify a return value for ALL cases or throw an exception for invalid values. One way to do this is by using the default case in your switch statement.
Here is an example:
C#
public class EventCode
   {
       public static string ToXml(Soap.EventCode.EvCodes value)
       {
           switch (value)
           {
               case Soap.EventCode.EvCodes.DispatchedForDelivery:
               case Soap.EventCode.EvCodes.Delivered:
                   return "OD";
               case Soap.EventCode.EvCodes.DepartedFromTerminal:
                   return "L1";
               // Catch-all for all other cases. 
               // Throwing an exception here is just an example implementation, not mandatory.
               default: throw new ArgumentOutOfRangeException(nameof(value), "Unsupported Evcode: " + value);

           }
       }
   }


modified 19-Oct-17 11:32am.

QuestionRead MS Access Code Files Using C# Pin
Kevin Marois22-Sep-17 7:20
professionalKevin Marois22-Sep-17 7:20 
AnswerRe: Read MS Access Code Files Using C# Pin
jschell22-Sep-17 8:47
jschell22-Sep-17 8:47 
GeneralRe: Read MS Access Code Files Using C# Pin
Kevin Marois22-Sep-17 9:06
professionalKevin Marois22-Sep-17 9:06 
GeneralRe: Read MS Access Code Files Using C# Pin
enhzflep22-Sep-17 10:47
enhzflep22-Sep-17 10:47 
GeneralRe: Read MS Access Code Files Using C# Pin
Kevin Marois22-Sep-17 11:49
professionalKevin Marois22-Sep-17 11:49 
GeneralRe: Read MS Access Code Files Using C# Pin
jschell26-Sep-17 6:11
jschell26-Sep-17 6:11 
GeneralRe: Read MS Access Code Files Using C# Pin
jschell26-Sep-17 6:08
jschell26-Sep-17 6:08 
AnswerRe: Read MS Access Code Files Using C# Pin
Joan M23-Sep-17 22:53
professionalJoan M23-Sep-17 22:53 
AnswerRe: Read MS Access Code Files Using C# Pin
Richard MacCutchan24-Sep-17 4:06
mveRichard MacCutchan24-Sep-17 4:06 
QuestionNeed help with API Values Pin
Bootzilla3322-Sep-17 3:17
Bootzilla3322-Sep-17 3:17 
AnswerRe: Need help with API Values Pin
Richard MacCutchan22-Sep-17 3:46
mveRichard MacCutchan22-Sep-17 3:46 
AnswerRe: Need help with API Values Pin
jschell22-Sep-17 8:58
jschell22-Sep-17 8:58 
QuestionDebug HTTP Vlient Handler (specifically cookies) in C# Pin
julian bechtold22-Sep-17 2:46
julian bechtold22-Sep-17 2:46 
Questionsplit method bug Pin
WoodChuckChuckles22-Sep-17 2:56
WoodChuckChuckles22-Sep-17 2:56 
AnswerRe: split method bug Pin
PIEBALDconsult22-Sep-17 2:51
mvePIEBALDconsult22-Sep-17 2:51 
GeneralRe: split method bug Pin
WoodChuckChuckles22-Sep-17 2:56
WoodChuckChuckles22-Sep-17 2:56 
AnswerRe: split method bug Pin
Richard MacCutchan22-Sep-17 3:44
mveRichard MacCutchan22-Sep-17 3:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.