RandomExtensionsNextObject(Random, Type, GenerateObjectSettings) Method
Returns a random object of the specified type or
if type cannot be instantiated with the provided settings.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public static Object? NextObject(
this Random random,
Type type,
GenerateObjectSettings? settings = null
)
<ExtensionAttribute>
Public Shared Function NextObject (
random As Random,
type As Type,
Optional settings As GenerateObjectSettings = Nothing
) As Object
public:
[ExtensionAttribute]
static Object^ NextObject(
Random^ random,
Type^ type,
GenerateObjectSettings^ settings = nullptr
)
[<ExtensionAttribute>]
static member NextObject :
random : Random *
type : Type *
?settings : GenerateObjectSettings
(* Defaults:
let _settings = defaultArg settings null
*)
-> Object
- random Random
- The Random instance to use.
- type Type
- The type of the object to be created. If TryResolveInterfacesAndAbstractTypes property
in settings is , then it can be also an interface or abstract type;
however, if no implementation or usable constructor found, then a value will be returned.
- settings GenerateObjectSettings (Optional)
- The settings to use or to use the default settings.
Default value: .
ObjectAn instance of
type or
if the type cannot be
instantiated with the provided
settings See the
Remarks section of the
NextObjectT(Random, GenerateObjectSettings) overload for details.In Visual Basic and C#, you can call this method as an instance method on any object of type
Random. 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).