| Oracle Data Provider for .NET Developer's Guide Release 9.2.0.2 Part Number A96160-01 |
|
Oracle.DataAccess.Types Namespace (ODP.NET Types), 7 of 17
The OracleString structure represents a variable-length stream of characters to be stored in or retrieved from a database.
Object
ValueType
OracleString
// C#
public struct OracleString : IComparable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
// C# // Illustrates the usage of OracleString // bytes1 is non-Unicode encoded byte array = AAAAA // bytes2 is Unicode encoded byte array = aa byte[] bytes1 = new byte[] {65,65,65,65,65}; byte[] bytes2 = new byte[] {97,0,97,0}; // set str1 = AAA // set str2 = a OracleString str1 = new OracleString(bytes1, 0, 3, false, true); OracleString str2 = new OracleString(bytes2, 2, 2, true, true); // Display the constructed strings Console.WriteLine("String str1 = " + str1.Value + ". Length = " + str1.Length); // Prints String str1 = AAA. Length = 3 Console.WriteLine("String str2 = " + str2.Value + ". Length = " + str2.Length); // Prints String str2 = a. Length = 1 while (str1 > str2) str2 = OracleString.Concat(str2,"a"); // Display the constructed strings Console.WriteLine("String str1 = " + str1.Value + ". Length = " + str1.Length); // Prints String str1 = AAA. Length= 3 Console.WriteLine("String str2 = " + str2.Value + ". Length = " + str2.Length); // Prints String str2 = aaa. Length= 3
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccesss.dll
OracleString members are listed in the following tables:
OracleString constructors are listed in Table 5-74
| Constructor | Description |
|---|---|
|
Instantiates a new instance of OracleString structure (Overloaded) |
The OracleString static fields are listed in Table 5-75.
| Field | Description |
|---|---|
|
Represents a null value that can be assigned to an instance of the |
The OracleString static methods are listed in Table 5-76.
The OracleString static operators are listed in Table 5-77.
The OracleString type conversions are listed in Table 5-78.
| Operator | Description |
|---|---|
|
Converts the supplied |
|
|
Converts the supplied |
The OracleString properties are listed in Table 5-79.
The OracleString methods are listed in Table 5-80.
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.
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.
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.
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);
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, boolfUnicode, boolisCaseIgnored);
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, intindex, intcount, boolfUnicode);
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 5-81.
| Field | Description |
|---|---|
|
Represents a null value that can be assigned to an instance of the |
This static field represents a null value that can be assigned to an instance of the OracleString structure.
// C# public static readonly OracleString Null;
The OracleString static methods are listed in Table 5-82.
This static method concatenates two OracleString instances and returns a new OracleString instance that represents the result.
// C# public static OracleString Concat(OracleStringstr1, OracleStringstr2);
An OracleString.
If either argument has a null value, the returned OracleString structure has a null value.
Overloads Object
This static method determines whether the two OracleStrings being compared are equal.
// C# public static bool Equals(OracleStringstr1, OracleStringstr2);
Returns true if the two OracleStrings being compared are equal; returns false otherwise.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
This static method determines whether the first of two OracleString values is greater than the second.
// C# public static bool GreaterThan(OracleStringstr1, OracleStringstr2);
Returns true if the first of two OracleStrings is greater than the second; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
This static method determines whether the first of two OracleString values is greater than or equal to the second.
// C#public static bool GreaterThanOrEqual(OracleStringstr1, OracleStringstr2);
Returns true if the first of two OracleStrings is greater than or equal to the second; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
This static method determines whether the first of two OracleString values is less than the second.
// C#
public static bool LessThan(OracleString str1, OracleString str2);
Returns true if the first is less than the second; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
This static method determines whether the first of two OracleString values is less than or equal to the second.
// C# public static bool LessThanOrEqual(OracleString str1, OracleString str2);
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.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings 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);
Returns true if the two OracleString instances are not equal; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
The OracleString static operators are listed in Table 5-83.
This static operator concatenates two OracleString values.
// C# public static OracleString operator + (OracleString value1, OracleString value2);
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);
Returns true if two OracleString values are equal; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings 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);
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.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings 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);
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.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings 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);
Returns true if two OracleString values are not equal; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
This static operator determines if the first of two OracleStrings is less than the second.
// C# public static bool operator < (OracleString value1, OracleString value2);
Returns true if the first of two OracleStrings is less than the second; otherwise, returns false.
The following rules apply to the behavior of this method.
OracleString that has a value is greater than an OracleString has a null value.
OracleStrings 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);
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.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
The OracleString type conversions are listed in Table 5-84.
| 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);
string
OracleNullValueException - The OracleString structure has a null value.
This type conversion operator converts the supplied string to an OracleString.
// C# public static implicit operator OracleString (string value1);
An OracleString.
The OracleString properties are listed in Table 5-85.
This property indicates whether 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# OracleString str1 = new OracleString("aAaAa"); OracleString str2 = new OracleString("AaAaA"); str1.IsCaseIgnored = true; str2.IsCaseIgnored = true; Console.WriteLine(str1.CompareTo(str2)); // Prints 0 // Note that IsCaseIgnored must be set to false for both OracleStrings // otherwise an exception is thrown str1.IsCaseIgnored = false; str2.IsCaseIgnored = false; Console.WriteLine(str1.CompareTo(str2)); // Prints non zero value
This property indicates whether 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.
This property returns the length of the OracleString.
// C# public int Length {get;}
A int value.
OracleNullValueException - The current instance has a null value.
The OracleString methods are listed in Table 5-86.
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# ... OracleString str_cloned = str.Clone(); ...
This method compares the current OracleString instance to the supplied object, and returns an integer that represents their relative values.
// C#public int CompareTo(objectobj);
The method returns a number that is:
OracleString value is less than obj.
OracleString value is equal to obj.
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.
OracleStrings. 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.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings that contain a null value are equal.
This method determines whether supplied object is an instance of OracleString and has the same values as the current OracleString instance.
// C# public override bool Equals(object obj);
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.
OracleString that has a value is greater than an OracleString that has a null value.
OracleStrings 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.
Overrides Object
This method converts the current OracleString instance to a string.
// C# public override string ToString();
A string.
If the current OracleString instance has a null value, the string contains "null".
|
|
![]() Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|