Namespaces in .NET scripts

Types in .NET Framework are organized into namespaces. This section describes the various ways in which such types can be used in .NET scripts.

Note. To use a type from a non-standard assembly, you must first add a reference to that assembly (see Assembly References in .NET Scripts for details).

Built-in types

Built-in types can be referenced just by name:

// C#
string str;

' Visual Basic .NET
Dim str As String

// JScript .NET
var str : String;

Likewise, no special syntax is required for referencing types from the FineReaderServer.ScriptingObjects.Interop namespace:

// C#
IAttribute attr;

' Visual Basic .NET
Dim attr As IAttribute

// JScript .NET
var attr : IAttribute;

Namespace qualifiers

To reference a user-defined type, you need to qualify its name with a namespace prefix:

// C#
var list = new System.Collections.ArrayList();

' Visual Basic .NET
Dim list As New System.Collections.ArrayList

Note. JScript .NET does not support this syntax.

Importing namespaces

To use of unqualified type names, their namespaces must be imported at the beginning of the script:

// C#
using System.Collections;
var list = new ArrayList();

' Visual Basic .NET
Imports System.Collections
Dim list As New ArrayList

// JScript .NET
import System.Collections;
var list = new ArrayList();

Note. Such import statements must appear at the very beginning of the script and may be preceded only by comments or empty lines.

If you use C# or Visual Basic .NET, you can declare aliases for types and namespaces:

// C#
using SC = System.Collections;
using AL = System.Collections.ArrayList;
var list_1 = new SC.ArrayList();
var list_2 = new AL();

' Visual Basic .NET
Imports SC = System.Collections
Imports AL = System.Collections.ArrayList
Dim list_1 As New SC.ArrayList
Dim list_2 As New AL

29.08.2023 11:55:30

Please leave your feedback about this article

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.