ClearScript Library
ClearScript Library
ClearScript Library Reference
Microsoft.ClearScript
HostFunctions Class
HostFunctions Methods
typeOf Method
typeOf<T> Method
typeOf(Object) Method

# HostFunctionstypeOf(Object) Method

Gets the Type for the specified host type. This version is invoked if the specified object cannot be used as a type argument.
Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntax
C#
VB
C++
F#
Copy

    public Type typeOf(
    	Object value
    )

    Public Function typeOf (
    	value As Object
    ) As Type

    public:
    Type^ typeOf(
    	Object^ value
    )

    member typeOf :
            value : Object -> Type

#### Parameters

value Object
  The host type for which to get the Type.

#### Return Value

Type
The Type for the specified host type.
Remarks

This function is similar to C#'s typeof operator. It is overloaded with typeOfT and selected at runtime if value cannot be used as a type argument. Note that this applies to some host types; examples are static types and overloaded generic type groups.

This function throws an exception if the script engine's AllowReflection property is set to false.

Example
The following code retrieves the assembly-qualified name of a host type. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
Copy

    var ConsoleT = host.type("System.Console");
    var name = host.typeOf(ConsoleT).AssemblyQualifiedName;

See Also

#### Reference

HostFunctions Class
typeOf Overload
Microsoft.ClearScript Namespace
type(String, Object)

Copyright © Microsoft Corporation. All rights reserved.

Send comments on this topic to Microsoft