PbArray<T> Class
.NET Standard 2.x
Defines a PowerBuilder-style array.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public class PbArray<T> : IEnumerable<T>
Constructors
Name | Description |
---|---|
PbArray() | Initializes an instance of PbArray<T> class. |
PbArray(int length) | Initializes an instance of PbArray<T> class. The size of the one-dimensional array is specified. |
PbArray(int length1, int length2) | Initializes an instance of PbArray<T> class. The size of the two-dimensional array is specified. |
Properties
Name | Return Type | Description |
---|---|---|
ElementType | type | Gets the data type of the elements of PbArray. |
Length | int | Gets the total number of elements in all the dimensions of PbArray. |
Item[int] | T | Gets or sets the element at the specified index. |
Item[int, int] | T | Gets or sets the element at the specified two-dimensional array. |
Methods
Name | Return Type | Description |
---|---|---|
Add(T value) | void | Adds an object to the end of the PbArray. |
GetEnumerator() | IEnumerator<T> | Returns an enumerator that iterates through the PbArray. |
GetLowerBound(int dimension) | int | Gets the index of the first element of the specified dimension in the PbArray. |
GetUpperBound(int dimension) | int | Gets the index of the last element of the specified dimension in the PbArray. |
GetValue(int index) | T | Gets the value of the specified element in the current PbArray. |
GetValue(int index1, int index2) | T | Gets the value at the specified position in the two-dimensional PbArray. |
SetValue(T value, int index) | void | Sets a value to the element at the specified position in the one-dimensional PbArray. |
SetValue(T value, int index1, int index2) | void | Sets a value to the element at the specified position in the two-dimensional PbArray. |
Operators
Name | Description |
---|---|
Implicit(T[,] to PbArray<T>) | Defines an implicit conversion which converts a two-dimensional object to a PbArray<T> object. |
Implicit(T[] to PbArray<T>) | Defines an implicit conversion which converts a one-dimensional object to a PbArray<T> object. |
Examples
The following code example demonstrates how to use the Add method to add the int-type data to PbArray, use the GetValue method to get the value of the element in PbArray, and use the SetValue method to modify the value of the element in PbArray.
using System;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.PbArrayExamples
{
public class PbArrayExample
{
public void Example()
{
// Creates a PbArray object which is the int type and has no fixed size
PbArray<int> pbArray = new PbArray<int>();
// Adds data to PbArray
pbArray.Add(1);
pbArray.Add(2);
pbArray.Add(3);
pbArray.Add(4);
pbArray.Add(5);
// Shows the data of pbArray
for(int index = 0; index < pbArray.Length; index++)
{
Console.WriteLine(pbArray.GetValue(index));
}
// Modifies the value of the 5th element to 0
pbArray.SetValue(0, 4);
//for (int index = 0; index < pbArray.Length; index++)
//{
// Console.WriteLine(pbArray.GetValue(index));
//}
Console.WriteLine();
for (int index = 0; index < pbArray.Length; index++)
{
Console.WriteLine(pbArray.GetValue(index));
}
/*This code produces the following output:
1
2
3
4
5
1
2
3
4
0
*/
}
}
}