The OracleString
structure represents a variable-length stream of characters to be stored in or retrieved from a database.
System.Object
System.ValueType
Oracle.DataAccess.Types.OracleString
// ADO.NET 2.0: C# public struct OracleString : IComparable, INullable, IXmlSerializable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
// C# using System; using Oracle.DataAccess.Types; class OracleStringSample { static void Main() { // Initialize OracleString structs OracleString string1 = new OracleString("AAA"); // Display the string "AAA" Console.WriteLine("{0} has length of {1}", string1, string1.Length); // Contatenate characters to string1 until the length is 5 while (string1.Length < 5) string1 = OracleString.Concat(string1,"a"); // Display the string of "AAAaa" Console.WriteLine("{0} has length of {1}", string1, string1.Length); } }
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccess.dll
ODP.NET Version: ODP.NET for .NET Framework 2.0 or ODP.NET for .NET Framework 4
See Also:
OracleString
members are listed in the following tables:
OracleString
constructors are listed in Table 14-74
Table 14-74 OracleString Constructors
Constructor | Description |
---|---|
Instantiates a new instance of |
The OracleString
static fields are listed in Table 14-75.
Table 14-75 OracleString Static Fields
Field | Description |
---|---|
Represents a null value that can be assigned to an instance of the |
The OracleString
static methods are listed in Table 14-76.
Table 14-76 OracleString Static Methods
Methods | Description |
---|---|
Concatenates two |
|
Determines if two |
|
Determines whether or not the first of two |
|
Determines whether or not the first of two |
|
Determines whether or not the first of two |
|
Determines whether or not the first of two |
|
Determines whether two |
The OracleString
static operators are listed in Table 14-77.
Table 14-77 OracleString Static Operators
Operator | Description |
---|---|
Concatenates two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the two |
|
Determines if the first of two |
|
Determines if two |
The OracleString
type conversions are listed in Table 14-78.
Table 14-78 OracleString Type Conversions
Operator | Description |
---|---|
Converts the supplied |
|
Converts the supplied |
The OracleString
properties are listed in Table 14-79.
Table 14-79 OracleString Properties
Properties | Description |
---|---|
Indicates whether or not case should be ignored when performing string comparison |
|
Indicates whether or not the current instance has a null value |
|
Obtains the particular character in an |
|
Returns the length of the |
The OracleString
methods are listed in Table 14-80.
Table 14-80 OracleString Methods
Methods | Description |
---|---|
Returns a copy of the current |
|
Compares the current |
|
Determines whether or not an object has the same string value as the current |
|
Returns a hash code for the |
|
Returns an array of bytes, containing the contents of the |
|
GetType |
Inherited from |
Returns an array of bytes, containing the contents of the |
|
Converts the current |
The OracleString
constructors create new instances of the OracleString
structure.
This constructor creates a new instance of the OracleString
structure and sets its value using a string.
This constructor creates a new instance of the OracleString
structure and sets its value using a string and specifies if case is ignored in comparison.
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array and specifies if the supplied byte array is Unicode encoded.
OracleString(byte [ ], bool, bool)
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array and specifies the following: if the supplied byte array is Unicode encoded and if case is ignored in comparison.
OracleString(byte [ ], int, int, bool)
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, and if the supplied byte array is Unicode encoded.
OracleString(byte [ ], int, int, bool, bool)
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, if the supplied byte array is Unicode encoded, and if case is ignored in comparison.
This constructor creates a new instance of the OracleString
structure and sets its value using a string.
// C#
public OracleString(string data);
data
A string value.
This constructor creates a new instance of the OracleString
structure and sets its value using a string and specifies if case is ignored in comparison.
// C# public OracleString(string data, bool isCaseIgnored);
data
A string value.
isCaseIgnored
Specifies if case is ignored in comparison. Specifies true
if case is to be ignored; otherwise, specifies false
.
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array and specifies if the supplied byte array is Unicode encoded.
// C# public OracleString(byte[] data, bool fUnicode);
data
Byte array data for the new OracleString
.
fUnicode
Specifies if the supplied data
is Unicode encoded. Specifies true
if Unicode encoded; otherwise, false
.
ArgumentNullException
- The data
parameter is null.
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array and specifies the following: if the supplied byte array is Unicode encoded and if case is ignored in comparison.
// C# public OracleString(byte[] data, bool fUnicode, bool isCaseIgnored);
data
Byte array data for the new OracleString
.
fUnicode
Specifies if the supplied data
is Unicode encoded. Specifies true
if Unicode encoded; otherwise, false
.
isCaseIgnored
Specifies if case is ignored in comparison. Specifies true
if case is to be ignored; otherwise, specifies false
.
ArgumentNullException
- The data
parameter is null.
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, and if the supplied byte array is Unicode encoded.
// C# public OracleString(byte[] data, int index, int count, bool fUnicode);
data
Byte array data for the new OracleString
.
index
The starting index to copy from data
.
count
The number of bytes to copy.
fUnicode
Specifies if the supplied data
is Unicode encoded. Specifies true
if Unicode encoded; otherwise, false
.
ArgumentNullException
- The data
parameter is null.
ArgumentOutOfRangeException
- The count
parameter is less than zero.
IndexOutOfRangeException
- The index
parameter is greater than or equal to the length of data
or less than zero.
This constructor creates a new instance of the OracleString
structure and sets its value using a byte array, and specifies the following: the starting index in the byte array, the number of bytes to copy from the byte array, if the supplied byte array is Unicode encoded, and if case is ignored in comparison.
// C# public OracleString(byte[] data, int index, int count, bool fUnicode, bool isCaseIgnored);
data
Byte array data for the new OracleString
.
index
The starting index to copy from data
.
count
The number of bytes to copy.
fUnicode
Specifies if the supplied data
is Unicode encoded. Specifies true
if Unicode encoded; otherwise, false
.
isCaseIgnored
Specifies if case is ignored in comparison. Specifies true
if case is to be ignored; otherwise, specifies false
.
ArgumentNullException
- The data
parameter is null.
ArgumentOutOfRangeException
- The count
parameter is less than zero.
IndexOutOfRangeException
- The index
parameter is greater than or equal to the length of data
or less than zero.
The OracleString
static fields are listed in Table 14-81.
Table 14-81 OracleString Static Fields
Field | Description |
---|---|
Represents a null value that can be assigned to an instance of the |
The OracleString
static methods are listed in Table 14-82.
Table 14-82 OracleString Static Methods
Methods | Description |
---|---|
Concatenates two |
|
Determines if two |
|
Determines whether or not the first of two |
|
Determines whether or not the first of two |
|
Determines whether or not the first of two |
|
Determines whether or not the first of two |
|
Determines whether two |
This static method concatenates two OracleString
instances and returns a new OracleString
instance that represents the result.
// C# public static OracleString Concat(OracleString str1, OracleString str2);
str1
The first OracleString.
str2
The second OracleString
.
An OracleString.
If either argument has a null value, the returned OracleString
structure has a null value.
Overloads Object
This static method determines whether or not the two OracleString
s being compared are equal.
// C# public static bool Equals(OracleString str1, OracleString str2);
str1
The first OracleString.
str2
The second OracleString.
Returns true
if the two OracleString
s being compared are equal; returns false
otherwise.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static method determines whether or not the first of two OracleString
values is greater than the second.
// C# public static bool GreaterThan(OracleString str1, OracleString str2);
str1
The first OracleString.
str2
The second OracleString.
Returns true
if the first of two OracleString
s is greater than the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static method determines whether or not the first of two OracleString
values is greater than or equal to the second.
// C# public static bool GreaterThanOrEqual(OracleString str1, OracleString str2);
str1
The first OracleString
.
str2
The second OracleString
.
Returns true
if the first of two OracleString
s is greater than or equal to the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static method determines whether or not the first of two OracleString
values is less than the second.
// C# public static bool LessThan(OracleString str1, OracleString str2);
str1
The first OracleString.
str2
The second OracleString.
Returns true
if the first is less than the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static method determines whether or not the first of two OracleString
values is less than or equal to the second.
// C# public static bool LessThanOrEqual(OracleString str1, OracleString str2);
str1
The first OracleString.
str2
The second OracleString.
Returns true
if the first is less than or equal to the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static method determines whether two OracleString
values are not equal.
// C# public static bool NotEquals(OracleString str1, OracleString str2);
str1
The first OracleString.
str2
The second OracleString.
Returns true
if the two OracleString
instances are not equal; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
The OracleString
static operators are listed in Table 14-83.
Table 14-83 OracleString Static Operators
Operator | Description |
---|---|
Concatenates two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the two |
|
Determines if the first of two |
|
Determines if two |
This static operator concatenates two OracleString
values.
// C# public static OracleString operator + (OracleString value1, OracleString value2);
value1
The first OracleString
.
value2
The second OracleString
.
An OracleString.
If either argument has a null value, the returned OracleString
structure has a null value.
This static operator determines if two OracleString
values are equal.
// C# public static bool operator == (OracleString value1, OracleString value2);
value1
The first OracleString
.
value2
The second OracleString
.
Returns true
if two OracleString
values are equal; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static operator determines if the first of two OracleString
values is greater than the second.
// C# public static bool operator > (OracleString value1, OracleString value2);
value1
The first OracleString
.
value2
The second OracleString
.
Returns true
if the first of two OracleString
values is greater than the second; otherwise returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static operator determines if the first of two OracleString
values is greater than or equal to the second.
// C# public static bool operator >= (OracleString value1, OracleString value2);
value1
The first OracleString
.
value2
The second OracleString
.
Returns true
if the first of two OracleString
values is greater than or equal to the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static operator determines if two OracleString
values are not equal.
// C# public static bool operator != (OracleString value1, OracleString value2);
value1
The first OracleString
.
value2
The second OracleString
.
Returns true
if two OracleString
values are not equal; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This static operator determines if the first of two OracleString
s is less than the second.
// C# public static bool operator < (OracleString value1, OracleString value2);
value1
The first OracleString
.
value2
The second OracleString
.
Returns true
if the first of two OracleString
s is less than the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
has a null value.
Two OracleString
s that contain a null value are equal.
This static operator determines if the first of two OracleString
values is less than or equal to the second.
// C# public static bool operator <= (OracleString value1, OracleString value1);
value1
The first OracleString
.
value2
The second OracleString
.
Returns true
if the first of two OracleString
values is less than or equal to the second; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
The OracleString
type conversions are listed in Table 14-84.
Table 14-84 OracleString Type Conversions
Operator | Description |
---|---|
Converts the supplied |
|
Converts the supplied |
This type conversion operator converts the supplied OracleString
to a string
.
//C#
public static explicit operator string (OracleString value1);
value1
The supplied OracleString
.
string
OracleNullValueException
- The OracleString
structure has a null value.
The OracleString
properties are listed in Table 14-85.
Table 14-85 OracleString Properties
Properties | Description |
---|---|
Indicates whether or not case should be ignored when performing string comparison |
|
Indicates whether or not the current instance has a null value |
|
Obtains the particular character in an |
|
Returns the length of the |
This property indicates whether or not case should be ignored when performing string comparison.
//C# public bool IsCaseIgnored {get;set;}
Returns true
if string comparison must ignore case; otherwise false
.
Default value is true
.
// C# using System; using Oracle.DataAccess.Types; class IsCaseIgnoredSample { static void Main() { OracleString string1 = new OracleString("aAaAa"); OracleString string2 = new OracleString("AaAaA"); // Ignore case for comparisons string1.IsCaseIgnored = true; string2.IsCaseIgnored = true; // Same; Prints 0 Console.WriteLine(string1.CompareTo(string2)); // Make comparisons case sensitive // Note that IsCaseIgnored must be set to false for both // OracleStrings; otherwise an exception is thrown string1.IsCaseIgnored = false; string2.IsCaseIgnored = false; // Different; Prints nonzero value Console.WriteLine(string1.CompareTo(string2)); } }
This property indicates whether or not the current instance contains a null value.
// C# public bool IsNull {get;}
Returns true
if the current instance contains has a null value; otherwise, returns false
.
This property obtains the particular character in an OracleString
using an index.
// C# public char Item {get;}
A char
value.
OracleNullValueException
- The current instance has a null value.
The OracleString
methods are listed in Table 14-86.
Table 14-86 OracleString Methods
Methods | Description |
---|---|
Returns a copy of the current |
|
Compares the current |
|
Determines whether or not an object has the same string value as the current |
|
Returns a hash code for the |
|
Returns an array of bytes, containing the contents of the |
|
GetType |
Inherited from |
Returns an array of bytes, containing the contents of the |
|
Converts the current |
This method creates a copy of an OracleString
instance.
// C# public OracleString Clone();
An OracleString
structure.
The cloned object has the same property values as that of the object being cloned.
// C# using System; using Oracle.DataAccess.Types; class CloneSample { static void Main() { OracleString str1 = new OracleString("aAaAa"); OracleString str2 = str1.Clone(); // The OracleStrings are same; Prints 0 Console.WriteLine(str1.CompareTo(str2)); } }
This method compares the current OracleString
instance to the supplied object, and returns an integer that represents their relative values.
// C# public int CompareTo(object obj);
obj
The object being compared to the current instance.
The method returns a number that is:
Less than zero: if the current OracleString
value is less than obj
.
Zero: if the current OracleString
value is equal to obj
.
Greater than zero: if the current OracleString
value is greater than obj
.
IComparable
ArgumentException
- The obj
parameter is not of type OracleString
.
The following rules apply to the behavior of this method.
The comparison must be between OracleString
s. For example, comparing an OracleString
instance with an OracleBinary
instance is not allowed. When an OracleString
is compared with a different type, an ArgumentException
is thrown.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
This method determines whether or not supplied object is an instance of OracleString
and has the same values as the current OracleString
instance.
// C#
public override bool Equals(object obj);
obj
An object being compared.
Returns true
if the supplied object is an instance of OracleString
and has the same values as the current OracleString
instance; otherwise, returns false
.
The following rules apply to the behavior of this method.
Any OracleString
that has a value is greater than an OracleString
that has a null value.
Two OracleString
s that contain a null value are equal.
Overrides Object
This method returns a hash code for the OracleString
instance.
// C# public override int GetHashCode();
A number that represents the hash code.
This method returns an array of bytes, containing the contents of the OracleString
, in the client character set format.
// C# public byte[] GetNonUnicodeBytes();
A byte array that contains the contents of the OracleString
in the client character set format.
If the current instance has a null value, an OracleNullValueException
is thrown.
This method returns an array of bytes, containing the contents of the OracleString
in Unicode format.
// C# public byte[] GetUnicodeBytes();
A byte array that contains the contents of the OracleString
in Unicode format.
If the current instance has a null value, an OracleNullValueException
is thrown.