Oracle® Data Provider for .NET Developer's Guide 11g Release 1 (11.1) Part Number B28375-01 |
|
|
View PDF |
The OracleBinary
structure represents a variable-length stream of binary data to be stored in or retrieved from a database.
Class Inheritance
System.Object
System.ValueType
Oracle.DataAccess.Types.OracleBinary
Declaration
// ADO.NET 2.0: C# public struct OracleBinary : IComparable, INullable, IXmlSerializable
// ADO.NET 1.x: C#public struct OracleBinary : IComparable, INullable
Thread Safety
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
Example
// C# using System; using Oracle.DataAccess.Types; class OracleBinarySample { static void Main(string[] args) { // Initialize the OracleBinary structures OracleBinary binary1= new OracleBinary(new byte[] {1,2,3,4,5}); OracleBinary binary2 = new OracleBinary(new byte[] {1,2,3}); OracleBinary binary3 = new OracleBinary(new byte[] {4,5}); OracleBinary binary4 = binary2 + binary3; // Compare binary1 and binary4; they're equal if (binary1 == binary4) Console.WriteLine("The two OracleBinary structs are equal"); else Console.WriteLine("The two OracleBinary structs are different"); } }
Requirements
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccess.dll
Microsoft .NET Framework Version: 1.x or 2.0
See Also:
OracleBinary
members are listed in the following tables:
OracleBinary Constructors
OracleBinary
constructors are listed in Table 12-1
Table 12-1 OracleBinary Constructors
Constructor | Description |
---|---|
Instantiates a new instance of |
OracleBinary Static Fields
The OracleBinary
static fields are listed in Table 12-2.
Table 12-2 OracleBinary Static Fields
Field | Description |
---|---|
Represents a null value that can be assigned to an instance of the |
OracleBinary Static Methods
The OracleBinary
static methods are listed in Table 12-3.
Table 12-3 OracleBinary Static Methods
Methods | Description |
---|---|
Returns the concatenation of two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if two |
OracleBinary Static Operators
The OracleBinary
static operators are listed in Table 12-4.
Table 12-4 OracleBinary Static Operators
Operator | Description |
---|---|
Concatenates two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
OracleBinary Static Type Conversion Operators
The OracleBinary
static type conversion operators are listed in Table 12-5.
Table 12-5 OracleBinary Static Type Conversion Operators
Operator | Description |
---|---|
Converts an instance value to a byte array |
|
Converts an instance value to an |
OracleBinary Properties
The OracleBinary
properties are listed in Table 12-6.
Table 12-6 OracleBinary Properties
Properties | Description |
---|---|
Indicates whether or not the current instance has a null value |
|
Obtains the particular |
|
Returns the length of the binary data |
|
Returns the binary data that is stored in an |
OracleBinary Instance Methods
The OracleBinary
instance methods are listed in Table 12-7.
Table 12-7 OracleBinary Instance Methods
Methods | Description |
---|---|
Compares the current instance to an object and returns an integer that represents their relative values |
|
Determines if two objects contain the same binary data (Overloaded) |
|
Returns a hash code for the current instance |
|
GetType |
Inherited from |
Converts the current |
The OracleBinary
constructor instantiates a new instance of the OracleBinary
structure and sets its value to the provided array of bytes.
Declaration
// C#
public OracleBinary(byte[ ] bytes);
Parameters
bytes
A byte array.
The OracleBinary
static fields are listed in Table 12-8.
Table 12-8 OracleBinary Static Fields
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 OracleBinary
structure.
Declaration
// C# public static readonly OracleBinary Null;
The OracleBinary
static methods are listed in Table 12-9.
Table 12-9 OracleBinary Static Methods
Methods | Description |
---|---|
Returns the concatenation of two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if two |
This method returns the concatenation of two OracleBinary
structures.
Declaration
// C# public static OracleBinary Concat(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
An OracleBinary
.
Remarks
If either argument has a null value, the returned OracleBinary
structure has a null value.
This method determines if two OracleBinary
values are equal.
Declaration
// C# public static bool Equals(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if two OracleBinary
values are equal; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines whether or not the first of two OracleBinary
values is greater than the second.
Declaration
// C# public static bool GreaterThan(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is greater than the second; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
Example
// C# using System; using Oracle.DataAccess.Types; class GreaterThanSample { static void Main(string[] args) { OracleBinary binary1 = OracleBinary.Null; OracleBinary binary2 = new OracleBinary(new byte[] {1}); // Compare two OracleBinary structs; binary1 < binary2 if (OracleBinary.GreaterThan(binary1, binary2)) Console.WriteLine("binary1 > binary2"); else Console.WriteLine("binary1 < binary2"); } }
This method determines whether or not the first of two OracleBinary
values is greater than or equal to the second.
Declaration
// C# public static bool GreaterThanOrEqual(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is greater than or equal to the second; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines whether or not the first of two OracleBinary
values is less than the second.
Declaration
// C# public static bool LessThan(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is less than the second; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines whether or not the first of two OracleBinary
values is less than or equal to the second.
Declaration
// C# public static bool LessThanOrEqual(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is less than or equal to the second; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines whether or not two OracleBinary
values are not equal.
Declaration
// C# public static bool NotEquals(OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if two OracleBinary
values are not equal; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
The OracleBinary
static operators are listed in Table 12-10.
Table 12-10 OracleBinary Static Operators
Operator | Description |
---|---|
Concatenates two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
This method concatenates two OracleBinary
values.
Declaration
// C# public static OracleBinary operator + (OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
OracleBinary
Remarks
If either argument has a null value, the returned OacleBinary
structure has a null value.
This method determines if two OracleBinary
values are equal.
Declaration
// C# public static bool operator == (OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if they are the same; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines if the first of two OracleBinary
values is greater than the second.
Declaration
// C# public static bool operator > (OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is greater than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
Example
// C# using System; using Oracle.DataAccess.Types; class OperatorSample { static void Main(string[] args) { OracleBinary binary1 = OracleBinary.Null; OracleBinary binary2 = new OracleBinary(new byte[] {1}); // Compare two OracleBinary structs; binary1 < binary2 if (binary1 > binary2) Console.WriteLine("binary1 > binary2"); else Console.WriteLine("binary1 < binary2"); } }
This method determines if the first of two OracleBinary
values is greater than or equal to the second.
Declaration
// C# public static bool operator >= (OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is greater than or equal to the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines if two OracleBinary
values are not equal.
Declaration
// C# public static bool operator != (OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the two OracleBinary
values are not equal; otherwise, returns false
.
This method determines if the first of two OracleBinary
values is less than the second.
Declaration
// C# public static bool operator < ( OracleBinary value1, OracleBinary value2);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is less than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
This method determines if the first of two OracleBinary
values is less than or equal to the second.
Declaration
// C# public static bool operator <= (OracleBinary value1, OracleBinary value1);
Parameters
value1
The first OracleBinary
.
value2
The second OracleBinary
.
Return Value
Returns true
if the first of two OracleBinary
values is less than or equal to the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
The OracleBinary
static type conversion operators are listed in Table 12-11.
Table 12-11 OracleBinary Static Type Conversion Operators
Operator | Description |
---|---|
Converts an instance value to a byte array |
|
Converts an instance value to an |
This method converts an OracleBinary
value to a byte array.
Declaration
// C#
public static explicit operator byte[ ] (OracleBinary val);
Parameters
val
An OracleBinary
.
Return Value
A byte array.
Exceptions
OracleNullValueException
- The OracleBinary
structure has a null value.
This method converts a byte array to an OracleBinary
structure.
Declaration
// C#
public static implicit operator OracleBinary(byte[ ] bytes);
Parameters
bytes
A byte array.
Return Value
OracleBinary
The OracleBinary
properties are listed in Table 12-12.
Table 12-12 OracleBinary Properties
Properties | Description |
---|---|
Indicates whether or not the current instance has a null value |
|
Obtains the particular |
|
Returns the length of the binary data |
|
Returns the binary data that is stored in an |
This property indicates whether or not the current instance has a null value.
Declaration
// C# public bool IsNull {get;}
Property Value
Returns true
if the current instance has a null value; otherwise returns false
.
This property obtains the particular byte
in an OracleBinary
structure using an index.
Declaration
// C# public byte this[int index] {get;}
Property Value
A byte in the specified index.
Exceptions
OracleNullValueException
- The current instance has a null value.
Example
// C# using System; using Oracle.DataAccess.Types; class ItemSample { static void Main(string[] args) { OracleBinary binary = new OracleBinary(new byte[] {1,2,3,4}); // Prints the value 4 Console.WriteLine(binary[binary.Length - 1]); } }
This property returns the length of the binary data.
Declaration
// C# public int length {get;}
Property Value
Length of the binary data.
Exceptions
OracleNullValueException
- The current instance has a null value.
Example
// C# using System; using Oracle.DataAccess.Types; class LengthSample { static void Main(string[] args) { OracleBinary binary = new OracleBinary(new byte[] {1,2,3,4}); // Prints the value 4 Console.WriteLine(binary.Length); } }
This property returns the binary data that is stored in the OracleBinary
structure.
Declaration
// C# public byte[] Value {get;}
Property Value
Binary data.
Exceptions
OracleNullValueException
- The current instance has a null value.
The OracleBinary
instance methods are listed in Table 12-13.
Table 12-13 OracleBinary Instance Methods
Methods | Description |
---|---|
Compares the current instance to an object and returns an integer that represents their relative values |
|
Determines if two objects contain the same binary data (Overloaded) |
|
Returns a hash code for the current instance |
|
GetType |
Inherited from |
Converts the current |
This method compares the current instance to an object and returns an integer that represents their relative values
Declaration
// C#
public int CompareTo(object obj);
Parameters
obj
The object being compared.
Return Value
The method returns a number that is:
Less than zero: if the current OracleBinary
instance value is less than obj
.
Zero: if the current OracleBinary
instance and obj
values have the same binary data.
Greater than zero: if the current OracleBinary
instance value is greater than obj
.
Implements
IComparable
Exceptions
ArgumentException
- The parameter is not of type OracleBinary
.
Remarks
The following rules apply to the behavior of this method.
The comparison must be between OracleBinary
s. For example, comparing an OracleBinary
instance with an OracleTimeStamp
instance is not allowed. When an OracleBinary
is compared with a different type, an ArgumentException
is thrown.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
Example
// C# using System; using Oracle.DataAccess.Types; class CompareToSample { static void Main(string[] args) { OracleBinary binary1 = new OracleBinary(new byte[] {1,2,3}); OracleBinary binary2 = new OracleBinary(new byte[] {1,2,3,4}); // Compare if (binary1.CompareTo(binary2) == 0) Console.WriteLine("binary1 is the same as binary2"); else Console.WriteLine("binary1 is different from binary2"); } }
This method determines whether or not an object is an instance of OracleBinary
, and has the same binary data as the current instance.
Declaration
// C#
public override bool Equals(object obj);
Parameters
obj
The object being compared.
Return Value
Returns true
if obj
is an instance of OracleBinary
, and has the same binary data as the current instance; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleBinary
that has a value is greater than an OracleBinary
that has a null value.
Two OracleBinary
s that contain a null value are equal.
Overrides Object
This method returns a hash code for the OracleBinary
instance.
Declaration
// C# public override int GetHashCode();
Return Value
An int
that represents the hash.
Overrides Object
This method converts an OracleBinary
instance to a string instance.
Declaration
// C# public override string ToString();
Return Value
string
Remarks
If the current OracleBinary
instance has a null value, the returned string "null"
.