C#에 익숙하지 않아 개체간에 변수가 전달되는 방식을 이해할 수 없습니다. 이 프로그램을 실행할 때 배열 변수 "filePaths"가 null로 돌아옵니다. 기본 Windows 양식입니다. 나는 단어를 보여주고 소리를 낼 프로그램을 만들고있다.다른 개체간에 변수에 액세스하는 C#
특정 오류는 여기
. NullReferenceException이 처리되지 않은였다 "내 특정 코드입니다.
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;
using System.IO;
using System.Media;
namespace Kindersect
{
public partial class form1 : Form
{
string[] filePaths;
string directpath = "C:\\Users\\Optimus Prime\\Documents\\vocabaudio\\";
int counter = 0;
int c = 0;
public form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
string[] filePaths = Directory.GetFiles(directpath, "*.wav");
foreach(string k in filePaths)
{
c++;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (counter < c)
{
label1.Text = filePaths[counter];
SoundPlayer simpleSound = new SoundPlayer(filePaths[counter]);
simpleSound.Play();
counter++;
}
}
}
} 사전에
감사합니다. 참조 할 때
옵티머스 프라임이 너무 컴퓨터를 사용하고 있습니다 : 그래서
...
도
페이지에 해당? 그 멋진 남자. – DarthVader
내가 가지고있는 선언 문제와 내가 가진 문제를 벗어나는 캐릭터를 설명해 주신 모든 분들께 감사드립니다. 내 새끼가 나를 배신했다. –
u는'noob'을 호출합니다. – DarthVader