Various extension methods for core data types.
InheritanceBasicExtensions
Namespace: DotNext Assembly: DotNext.dll Syntaxpublic static class BasicExtensions
Methods | Edit this page View Source As<T>(T)
Reinterprets object reference.
Declarationpublic static T As<T>(this T obj) where T : class?
Parameters Type Name Description T obj
The object reference to reinterpret.
Returns Type Description TThe reinterpreted obj
reference.
The target type.
ExamplesMemoryManager<T> manager;
manager.As<IDisposable>().Dispose();
| Edit this page View Source Disclosed<T>(T)
Creates disclosed range endpoint.
Declarationpublic static DisclosedEndpoint<T> Disclosed<T>(this T value) where T : IComparable<T>
Parameters Type Name Description T value
The endpoint value.
Returns Type Parameters Name Description TThe type of the endpoint.
See Also | Edit this page View Source Enclosed<T>(T)Creates enclosed range endpoint.
Declarationpublic static EnclosedEndpoint<T> Enclosed<T>(this T value) where T : IComparable<T>
Parameters Type Name Description T value
The endpoint value.
Returns Type Parameters Name Description TThe type of the endpoint.
See Also | Edit this page View Source GetUserData<T>(T)Provides ad-hoc approach to associate some data with the object without modification of it.
Declarationpublic static UserDataStorage GetUserData<T>(this T obj) where T : class
Parameters Type Name Description T obj
Target object.
Returns Type Parameters Name Description TThe type of the object.
| Edit this page View Source IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)Determines whether the specified value is in the specified range.
Declarationpublic static bool IsBetween<T, TLowerBound, TUpperBound>(this T value, TLowerBound lowerBound, TUpperBound upperBound) where T : notnull where TLowerBound : IRangeEndpoint<T> where TUpperBound : IRangeEndpoint<T>
Parameters Type Name Description T value
The value to compare.
TLowerBound lowerBoundThe lower bound.
TUpperBound upperBoundThe upper bound.
Returns Type Description booltrue if value
is in the specified range; otherwise, false.
The type of the value.
TLowerBoundThe lower bound type.
TUpperBoundThe upper bound type.
ExamplesThe following example demonstrates how to check whether the value is in range [0..1).
double x;
IsBetween(x, 0D.Enclosed(), 1D.Disclosed());
See Also | Edit this page View Source IsNullOrEmpty(Array?)
Indicates that array is null or empty.
Declarationpublic static bool IsNullOrEmpty(this Array? array)
Parameters Type Name Description Array array
The array to check.
Returns | Edit this page View Source IsOneOf<T>(T, ReadOnlySpan<T>)Checks whether the specified object is equal to one of the specified objects.
Declarationpublic static bool IsOneOf<T>(this T value, ReadOnlySpan<T> candidates)
Parameters Type Name Description T value
The object to compare with other.
ReadOnlySpan<T> candidatesCandidate objects.
Returns Type Description booltrue, if value
is equal to one of candidates
.
The type of object to compare.
| Edit this page View Source TryGetValue<T>(T?, out T)Attempts to get value from nullable container.
Declarationpublic static bool TryGetValue<T>(this T? nullable, out T value) where T : struct
Parameters Type Name Description T? nullable
Nullable value.
T valueUnderlying value.
Returns Type Parameters Name Description TThe underlying value type of the nullable type.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4