UtilReflectionGetFieldValueT(Object, String, T, BindingFlags) Method
Searches for the specified field in the specified object, and returns the field value.
Namespace: DevCase.Core.Diagnostics.Assembly.ReflectionAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static T GetFieldValue<T>(
Object obj,
string fieldName,
T defaultIfEmpty,
BindingFlags bindingFlags = BindingFlags.Instance|BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.FlattenHierarchy|BindingFlags.GetProperty
)
Public Shared Function GetFieldValue(Of T) (
obj As Object,
fieldName As String,
defaultIfEmpty As T,
Optional bindingFlags As BindingFlags = BindingFlags.Instance Or BindingFlags.Static Or BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.FlattenHierarchy Or BindingFlags.GetProperty
) As T
Dim obj As Object
Dim fieldName As String
Dim defaultIfEmpty As T
Dim bindingFlags As BindingFlags
Dim returnValue As T
returnValue = UtilReflection.GetFieldValue(obj,
fieldName, defaultIfEmpty, bindingFlags)
public:
generic<typename T>
static T GetFieldValue(
Object^ obj,
String^ fieldName,
T defaultIfEmpty,
BindingFlags bindingFlags = BindingFlags::Instance|BindingFlags::Static|BindingFlags::Public|BindingFlags::NonPublic|BindingFlags::FlattenHierarchy|BindingFlags::GetProperty
)
static member GetFieldValue :
obj : Object *
fieldName : string *
defaultIfEmpty : 'T *
?bindingFlags : BindingFlags
(* Defaults:
let _bindingFlags = defaultArg bindingFlags BindingFlags.Instance|BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.FlattenHierarchy|BindingFlags.GetProperty
*)
-> 'T
No code example is currently available or this language may not be supported.
- obj Object
-
The source object from which to retrieve the field.
- fieldName String
-
The name of the field to search for.
- defaultIfEmpty T
-
The default value to return in case of the property value is .
- bindingFlags BindingFlags (Optional)
-
Flags that controls binding and the way in which the search for members and types is conducted by Reflection.
- T
-
The type of the field to be returned.
T
The field value.
This is a code example.
No code example is currently available or this language may not be supported.
' Declare a field
Public MyField As String = Nothing
' Get the declared field
Dim field As String = GetFieldValue(Of String)(Me, "MyField", "Default value if null")
Console.WriteLine(field)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
ArgumentNullException
|
|
ArgumentException
|
Field not found using the current flags.
|