当前位置: 首页 > 工具软件 > ConvertAll > 使用案例 >

Array.ConvertAll 範例 (C#)

伊羽
2023-12-01
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Array_ConvertAll_CSharp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string[] sArray = new string[]{"1.01","3.02"};  
            double[] dArray = Array.ConvertAll<string, double>(sArray, value => Convert.ToDouble(value));
            MessageBox.Show((dArray[1] - dArray[0]).ToString());
        }
    }
}
 类似资料: