txtinput の元のテキストはこの形式で表示されます
Firstportion Seconportion
Firstportion Seconportion
Firstportion Seconportion
Firstportion Seconportion
私の目標は、最初に各行を2つの変数に分割し、それらを配列またはリストなどに追加することです[行数は可変であるため、配列は機能しません]
var1[] = firstportion, var2=seconportion //これまでのところ、最初のエントリで機能しているように見えます
それらを変数配列/リストに入れます[現在持っているループでは機能しません]
最初の部分を別々に処理し、2 番目の部分を条件付き if と正規表現で別々に処理し、それらをすべて 2 番目の txtbox に表示します
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using System.Collections; using System.Text.RegularExpressions; namespace Projectx { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string rawInput = txtInput.Text; //string[] rawInput = txtInput.Text.Split('\n'); int x = 1; int y = 1; foreach (string line in txtInput.Lines) { string firstPortion= ""; string secondPortion = ""; string[] splitInput = Regex.Split(rawInput, ("\\s+")); firstPortion= splitInput[0]; secondPortion = splitInput[1]; //##### This works so far ans splits each line into two variables seperated by 1 white space but not sure if it works for 2nd line and seems can't assign these new splited values into two seperate array or list with the same loop or seperate loop //List<int> list = new List<int>; //(arr) List<string> myList1 = new List<string>(); List<string> myList2 = new List<string>(); myList1.Add(firtPortion); myList2.Add(secondPortion); txtOutPut.Text = "modified " + myList1[x] + " " + myList2[y]+"\r\n"; int i = 1; i++; x++; y++; } } } }