-
Notifications
You must be signed in to change notification settings - Fork 36
M_CodeJam_Xml_XNodeExtensions_ElementAltValueOrDefault__1
Andrew Koryavchenko edited this page Jun 17, 2018
·
6 revisions
Returns value of optional element.
Namespace: CodeJam.Xml
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static T ElementAltValueOrDefault<T>(
this XElement parent,
Func<XElement, T> valueSelector,
T defaultValue,
params XName[] names
)
VB
<ExtensionAttribute>
Public Shared Function ElementAltValueOrDefault(Of T) (
parent As XElement,
valueSelector As Func(Of XElement, T),
defaultValue As T,
ParamArray names As XName()
) As T
F#
[<ExtensionAttribute>]
static member ElementAltValueOrDefault :
parent : XElement *
valueSelector : Func<XElement, 'T> *
defaultValue : 'T *
names : XName[] -> 'T
- parent
- Type: System.Xml.Linq.XElement
Parent element. - valueSelector
- Type: System.Func(XElement, T)
Function to select element value - defaultValue
- Type: T
Default value. - names
- Type: System.Xml.Linq.XName[]
Array of possible element names.
- T
- Type of value
Type: T
Selected element value or defaultValue if element does not exist.
In Visual Basic and C#, you can call this method as an instance method on any object of type XElement. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exception | Condition |
---|---|
ArgumentNullException | parent or valueSelector or names is null. |