固定長配列への変換

Namespace: FVIL
Assembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)

Syntax

C#
public virtual DPNT_T[] ToArray()
Visual Basic
Public Overridable Function ToArray As DPNT_T()

Return Value

Type: array<DPNT_T>[]()[][]
このインスタンスが保有する配列の全要素の複製を固定長配列に格納して返します。

Examples

ソースコード:
C# Copy imageCopy
using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace User.SampleCode.Array
{
    public partial class DPNT_T_ARRAY
    {
        /// <summary>
        /// 固定長配列への変換.
        /// </summary>
        [FvPluginExecute]
        public void ToArray()
        {
            int countOrg = 10;

            // 0) 配列の作成.
            List<fvalgcli.DPNT_T> list = new List<fvalgcli.DPNT_T>(countOrg);

            for (int i = 0; i < countOrg; i++)
            {
                list.Add(fvalgcli.DPNT_T.init(i * 10 + i, i * 10 + i));
            }

            // 1) インスタンスの準備と生成.
            FVIL.DPNT_T_ARRAY src1 = new FVIL.DPNT_T_ARRAY(list);

            fvalgcli.DPNT_T_PTR srcAddress = src1.Address;
            int srcCount = src1.Count;
            bool srcIsAttach = src1.IsAttach;

            // 2) 固定長配列への変換.
            fvalgcli.DPNT_T[] 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].x == src2[i].x
                            && list[i].y == src2[i].y,
                            "src2[{0}]: x={1},y={2})", i, src2[i].x, src2[i].y);

                Console.WriteLine("src2[{0}]: x={1},y={2})", i, src2[i].x, src2[i].y);
            }
        }
    }
}


Visual Basic Copy imageCopy
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Namespace SampleCode.Array
    Public Partial Class DPNT_T_ARRAY
        ''' <summary>
        ''' 固定長配列への変換.
        ''' </summary>
        <FvPluginExecute> _
        Public Sub ToArray()
            Dim countOrg As Integer = 10

            ' 0) 配列の作成.
            Dim list As New List(Of fvalgcli.DPNT_T)(countOrg)

            For i As Integer = 0 To countOrg - 1
                list.Add(fvalgcli.DPNT_T.init(i * 10 + i, i * 10 + i))
            Next

            ' 1) インスタンスの準備と生成.
            Dim src1 As New FVIL.DPNT_T_ARRAY(list)

            Dim srcAddress As fvalgcli.DPNT_T_PTR = src1.Address
            Dim srcCount As Integer = src1.Count
            Dim srcIsAttach As Boolean = src1.IsAttach

            ' 2) 固定長配列への変換.
            Dim src2 As fvalgcli.DPNT_T() = 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).x = src2(i).x AndAlso list(i).y = src2(i).y, "src2[{0}]: x={1},y={2})", i, src2(i).x, src2(i).y)

                Console.WriteLine("src2[{0}]: x={1},y={2})", i, src2(i).x, src2(i).y)
            Next
        End Sub
    End Class
End Namespace

See Also