코드의 목적은 .txt 파일에서로드 한 다음 임의로 선을로드하여 디스플레이. 나는 그걸 만지작 거 렸고 좀 더 도움이 필요해. 어떤 도움을 주시면 감사하겠습니다. 조정이 필요한 부분은 주석 처리되어 있습니다. 사용할 수있는 다음이 코드를 .txt 파일에서로드하고 무작위로 선을 선택하는 데 도움이 필요합니다.
string[] array = File.ReadAllLines("path");
을 그리고 :
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
namespace EquityPicks
{
public partial class MainForm : Form
{
public List<string> appList = new List<string>(7);
public MainForm()
{
InitializeComponent();
loadList();
}
public void loadList() // Adjust to load from a text File
{
appList.Clear();
for(int i =0; i<10; i++)
{
string text;
using (var streamReader = new StreamReader(@"c:\file.txt", Encoding.UTF8))
{
text = streamReader.ReadToEnd();
}
}
nextUpTextBox.Text = getMember();
onDeckTextBox.Text = getMember();
studentsLeftTextBox.Text = appList.Count.ToString();
}
public string getMember() // Adjust for Randomness
{
string member = appList[0];
appList.RemoveAt(0);
return member;
}
void NextButtonClick(object sender, EventArgs e)
{
if(appList.Count >= 1)
{
nextUpTextBox.Text = onDeckTextBox.Text;
onDeckTextBox.Text = getMember();
}
else if (appList.Count == 0)
{
nextUpTextBox.Text = onDeckTextBox.Text;
onDeckTextBox.Text = "";
}
else
{
nextUpTextBox.Text = "";
onDeckTextBox.Text = "";
}
studentsLeftTextBox.Text = appList.Count.ToString();
}
void ResetButtonClick(object sender, EventArgs e)
{
loadList();
}
}
}
이 큰 숙제를 만들 것 그것 같은 소리! – adv12
냄새 :'for (int i = 0; i <10; i ++)'. * 마술 번호 *'10 '은 무엇을 의미합니까? 이전 코드의 –
부분을 삭제했습니다. person이라는 새로운 문자열을 만든 다음 값을 늘려 끝에 숫자를 추가했습니다. –