Click here to Skip to main content
15,885,244 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 6:15
Bootzilla3321-Sep-17 6:15 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming21-Sep-17 6:19
mveRichard Deeming21-Sep-17 6:19 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 6:40
Bootzilla3321-Sep-17 6:40 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3321-Sep-17 18:19
Bootzilla3321-Sep-17 18:19 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3322-Sep-17 2:54
Bootzilla3322-Sep-17 2:54 
AnswerRe: How to handle multiple exceptions(Try..Catch) Pin
eddieangel19-Sep-17 6:07
eddieangel19-Sep-17 6:07 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 6:14
Bootzilla3319-Sep-17 6:14 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
eddieangel19-Sep-17 6:30
eddieangel19-Sep-17 6:30 
I am not sure what the validation looks like for your situation, but there are a couple of methods.

The most simple is to validate to see if the string exists.


C#
if (string.isNullOrEmpty(apiVariableName)) { return ; }


Since the first two bold items are static text there really isn't anything to validate there unless there is something else we aren't seeing. That said, one of the best methods to validate your data is to set validation attributes on your model class (Data.General.Shipment() and write a method that validates that. For example:


C#
internal class Shipment {
        [Required]
        [StringLength(12)]
        public string ShippingNumber { get; set; }

        [Required(ErrorMessage = "City cannot be empty.")]
        public string City { get; set; }

        [Required(ErrorMessage = "Zip is Required")]
        [RegularExpression(@"^\d{5}(-\d{4})?$", ErrorMessage = "Invalid Zip")]
        public string PostalCode { get; set; }
    }


The trick here is that you really want to leave your model validating to the model or validator class and not be trying to validate when you are building the XML. It is good defensive programming to cover null possibilities and such, but you really want to uncomplicate things as much as possible if you are crafting an XML by hand.
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 6:58
Bootzilla3319-Sep-17 6:58 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
eddieangel19-Sep-17 7:17
eddieangel19-Sep-17 7:17 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 7:28
Bootzilla3319-Sep-17 7:28 
QuestionXSL to get only elements which have no childs Pin
MrKBA18-Sep-17 23:27
MrKBA18-Sep-17 23:27 
AnswerRe: XSL to get only elements which have no childs Pin
Pete O'Hanlon18-Sep-17 23:49
mvePete O'Hanlon18-Sep-17 23:49 
GeneralRe: XSL to get only elements which have no childs Pin
MrKBA19-Sep-17 0:26
MrKBA19-Sep-17 0:26 
Questioni need Visual Studio .NET 2002 prerequisites cd Pin
michael nabil18-Sep-17 23:05
michael nabil18-Sep-17 23:05 
AnswerRe: i need Visual Studio .NET 2002 prerequisites cd Pin
OriginalGriff18-Sep-17 23:14
mveOriginalGriff18-Sep-17 23:14 
QuestionMessage Closed Pin
16-Sep-17 18:15
professionalHardevsinh Mori16-Sep-17 18:15 
AnswerRe: SQLTransaction Pin
OriginalGriff16-Sep-17 19:57
mveOriginalGriff16-Sep-17 19:57 
GeneralRe: SQLTransaction Pin
Hardevsinh Mori16-Sep-17 20:24
professionalHardevsinh Mori16-Sep-17 20:24 
GeneralRe: SQLTransaction Pin
Hardevsinh Mori16-Sep-17 20:26
professionalHardevsinh Mori16-Sep-17 20:26 
GeneralRe: SQLTransaction Pin
OriginalGriff16-Sep-17 21:44
mveOriginalGriff16-Sep-17 21:44 
GeneralRe: SQLTransaction Pin
Hardevsinh Mori16-Sep-17 21:47
professionalHardevsinh Mori16-Sep-17 21:47 
GeneralRe: SQLTransaction Pin
OriginalGriff16-Sep-17 21:49
mveOriginalGriff16-Sep-17 21:49 
GeneralRe: SQLTransaction Pin
Hardevsinh Mori16-Sep-17 21:51
professionalHardevsinh Mori16-Sep-17 21:51 
GeneralRe: SQLTransaction Pin
OriginalGriff16-Sep-17 21:58
mveOriginalGriff16-Sep-17 21:58 

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.