Android Guides | Samples

Java.Lang.Class.ForName Method

Returns a Class object which represents the class with the given name.

Syntax

[Android.Runtime.Register("forName", "(Ljava/lang/String;)Ljava/lang/Class;", "")]
public static Class ForName (String className)

Parameters

className

Exceptions

TypeReason
ClassNotFoundExceptionif the requested class cannot be found.
LinkageErrorif an error occurs during linkage
ExceptionInInitializerErrorif an exception occurs during static initialization of a class.

Remarks

Returns a Class object which represents the class with the given name. The name should be the name of a non-primitive class, as described in the Class. Primitive types can not be found using this method; use int.class or Integer.TYPE instead.

If the class has not yet been loaded, it is loaded and initialized first. This is done through either the class loader of the calling class or one of its parent class loaders. It is possible that a static initializer is run as a result of this call.

[Android Documentation]

Requirements

Namespace: Java.Lang
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1