固定長配列への変換
Namespace: FVILAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
public virtual F_LH_LINE[] ToArray() |
Visual Basic |
---|
Public Overridable Function ToArray As F_LH_LINE() |
Return Value
Type: array<F_LH_LINE>[]()[][]このインスタンスが保有する配列の全要素の複製を固定長配列に格納して返します。
Examples
ソースコード:
C# | Copy |
---|---|
using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace User.SampleCode.Array { public partial class F_LH_LINE_ARRAY { /// <summary> /// 固定長配列への変換. /// </summary> [FvPluginExecute] public void ToArray() { int countOrg = 10; // 0) 配列の作成. List<fvalgcli.F_LH_LINE> list = new List<fvalgcli.F_LH_LINE>(countOrg); for (int i = 0; i < countOrg; i++) { list.Add(fvalgcli.F_LH_LINE.init(i * 10 + i, i * 10 + i, i * 10 + i, i, i)); } // 1) インスタンスの準備と生成. FVIL.F_LH_LINE_ARRAY src1 = new FVIL.F_LH_LINE_ARRAY(list); fvalgcli.F_LH_LINE_PTR srcAddress = src1.Address; int srcCount = src1.Count; bool srcIsAttach = src1.IsAttach; // 2) 固定長配列への変換. fvalgcli.F_LH_LINE[] src2 = src1.ToArray(); // E) 確認 Assert.IsTrue(src2.Length == srcCount, "src2.Length = {0}", src2.Length); for (int i = 0; i < src2.Length; i++) { Assert.IsTrue(list[i].a == src2[i].a && list[i].b == src2[i].b && list[i].c == src2[i].c && list[i].q == src2[i].q && list[i].score == src2[i].score, "src2[{0}]: a={1},b={2},c={3},q={3},score={3}", i, src2[i].a, src2[i].b, src2[i].c, src2[i].q, src2[i].score); Console.WriteLine("src2[{0}]: a={1},b={2},c={3},q={3},score={3}", i, src2[i].a, src2[i].b, src2[i].c, src2[i].q, src2[i].score); } } } } |
Visual Basic | Copy |
---|---|
Imports System.Collections.Generic Imports System.Text Imports fvalgcli Namespace SampleCode.Array Public Partial Class F_LH_LINE_ARRAY ''' <summary> ''' 固定長配列への変換. ''' </summary> <FvPluginExecute> _ Public Sub ToArray() Dim countOrg As Integer = 10 ' 0) 配列の作成. Dim list As New List(Of fvalgcli.F_LH_LINE)(countOrg) For i As Integer = 0 To countOrg - 1 list.Add(fvalgcli.F_LH_LINE.init(i * 10 + i, i * 10 + i, i * 10 + i, i, i)) Next ' 1) インスタンスの準備と生成. Dim src1 As New FVIL.F_LH_LINE_ARRAY(list) Dim srcAddress As fvalgcli.F_LH_LINE_PTR = src1.Address Dim srcCount As Integer = src1.Count Dim srcIsAttach As Boolean = src1.IsAttach ' 2) 固定長配列への変換. Dim src2 As fvalgcli.F_LH_LINE() = src1.ToArray() ' E) 確認 Assert.IsTrue(src2.Length = srcCount, "src2.Length = {0}", src2.Length) For i As Integer = 0 To src2.Length - 1 Assert.IsTrue(list(i).a = src2(i).a AndAlso list(i).b = src2(i).b AndAlso list(i).c = src2(i).c AndAlso list(i).q = src2(i).q AndAlso list(i).score = src2(i).score, "src2[{0}]: a={1},b={2},c={3},q={3},score={3}", i, src2(i).a, src2(i).b, src2(i).c, _ src2(i).q, src2(i).score) Console.WriteLine("src2[{0}]: a={1},b={2},c={3},q={3},score={3}", i, src2(i).a, src2(i).b, src2(i).c, src2(i).q, _ src2(i).score) Next End Sub End Class End Namespace |