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