Click or drag to resize

collectionExtensionsgetFirstOfTypeT Method

imbSCI | imbACE | imbNLP | imbWEM | imbWBI
Gets the first instance that is compatibile with T in supplied collection. Supports PropertyCollection and other collections

Namespace:  imbSCI.Core.extensions.data
Assembly:  imbSCI.Core (in imbSCI.Core.dll) Version: 0.3.58.
Syntax
C#
public static T getFirstOfType<T>(
	this IEnumerable source,
	bool makeNewIfNotFound = false,
	Object defaultReturn = null,
	bool disableException = false
)
Request Example View Source

Parameters

source
Type: System.CollectionsIEnumerable
The source collection to search in
makeNewIfNotFound (Optional)
Type: SystemBoolean
if set to true [make new if not found].
defaultReturn (Optional)
Type: SystemObject
The default return.
disableException (Optional)
Type: SystemBoolean
if set to true it will not throw exception if item not found

Type Parameters

T
Type to test against using is keyword

Return Value

Type: T
Instance of type

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable. 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).
Exceptions
ExceptionCondition
[!:aceGeneralException]Resource of type " + typeof(T).Name + " not supplied in the resources collection
Remarks
Uses is keyword to test.
See Also