のために働いていない間、私は、これはちょうど私の疲れた目にはそう見てください見ていないいくつかの愚かなことだと確信している:C#のループが何らかの理由
int NoteCounter = 0;
int MaxNotes = 100;
string SongSegment = "";
Random NoteIndexGen = new Random();
while (NoteCounter <= MaxNotes)
{
int NoteIndex = NoteIndexGen.Next(1, 7);
#region SetNotes
switch (Key)
{
case "C-Maj":
switch (NoteIndex)
{
case 1:
SongSegment += " C ";
OutputInfo1.Text = SongSegment;
break;
case 2:
SongSegment += " D ";
OutputInfo1.Text = SongSegment;
break;
case 3:
SongSegment += " E ";
OutputInfo1.Text = SongSegment;
break;
case 4:
SongSegment += " F ";
OutputInfo1.Text = SongSegment;
break;
case 5:
SongSegment += " G ";
OutputInfo1.Text = SongSegment;
break;
case 6:
SongSegment += " A ";
OutputInfo1.Text = SongSegment;
break;
case 7:
SongSegment += " B ";
OutputInfo1.Text = SongSegment;
break;
}
break;
case "G-Mag":
switch (NoteIndex)
{
case 1:
SongSegment += " G ";
OutputInfo1.Text = SongSegment;
break;
case 2:
SongSegment += " A ";
OutputInfo1.Text = SongSegment;
break;
case 3:
SongSegment += " B ";
OutputInfo1.Text = SongSegment;
break;
case 4:
SongSegment += " C ";
OutputInfo1.Text = SongSegment;
break;
case 5:
SongSegment += " D ";
OutputInfo1.Text = SongSegment;
break;
case 6:
SongSegment += " E ";
OutputInfo1.Text = SongSegment;
break;
case 7:
SongSegment += " F# ";
OutputInfo1.Text = SongSegment;
break;
}
break;
case "D-Maj":
switch (NoteIndex)
{
case 1:
SongSegment += " D ";
OutputInfo1.Text = SongSegment;
break;
case 2:
SongSegment += " E ";
OutputInfo1.Text = SongSegment;
break;
case 3:
SongSegment += " F# ";
OutputInfo1.Text = SongSegment;
break;
case 4:
SongSegment += " G ";
OutputInfo1.Text = SongSegment;
break;
case 5:
SongSegment += " A ";
OutputInfo1.Text = SongSegment;
break;
case 6:
SongSegment += " B ";
OutputInfo1.Text = SongSegment;
break;
case 7:
SongSegment += " C# ";
OutputInfo1.Text = SongSegment;
break;
}
break;
case "A-Maj":
switch (NoteIndex)
{
case 1:
SongSegment += " A ";
OutputInfo1.Text = SongSegment;
break;
case 2:
SongSegment += " B ";
OutputInfo1.Text = SongSegment;
break;
case 3:
SongSegment += " C# ";
OutputInfo1.Text = SongSegment;
break;
case 4:
SongSegment += " D ";
OutputInfo1.Text = SongSegment;
break;
case 5:
SongSegment += " E ";
OutputInfo1.Text = SongSegment;
break;
case 6:
SongSegment += " F# ";
OutputInfo1.Text = SongSegment;
break;
case 7:
SongSegment += " G# ";
OutputInfo1.Text = SongSegment;
break;
}
break;
case "E-Maj":
switch (NoteIndex)
{
case 1:
SongSegment += " E ";
OutputInfo1.Text = SongSegment;
break;
case 2:
SongSegment += " F# ";
OutputInfo1.Text = SongSegment;
break;
case 3:
SongSegment += " G# ";
OutputInfo1.Text = SongSegment;
break;
case 4:
SongSegment += " A ";
OutputInfo1.Text = SongSegment;
break;
case 5:
SongSegment += " B ";
OutputInfo1.Text = SongSegment;
break;
case 6:
SongSegment += " C# ";
OutputInfo1.Text = SongSegment;
break;
case 7:
SongSegment += " D# ";
OutputInfo1.Text = SongSegment;
break;
}
break;
}
NoteCounter++;
#endregion SetNotes
#endregion GenerateMusic
break;
}
あなたは、私が作っていますことを考え出したかもしれません私は後に拡大していきますが、仕事へのそのためには、私はノートを文字列に追加するSongSegment
が必要RichTextBox
での出力がそうのような、しかし一つだけのノートである事のランダム音楽ジェネレータの種類:
A
私がキャッチしなかったものを見ますか?
あなたの最後の '休憩を。 'を削除する必要があります。 –
あなたの目は、過度の押し込みのためにおそらく疲れています。 –
デバッガ(ここに投稿した不完全でコンパイル不可能な抜粋ではなく、実際のコードで使用されています)は、これをかなり早く把握できるはずです。実際の[mcve]を提供していないので、特に恐ろしくインデントされた部分的なコードを提供すると、私たちの言うことはかなり難しいです。 –