将for循环内部的值传递到for循环窗口phone 7外部



我正在尝试获取for循环中变量a的值。对于下面的代码,我试图将值输出到变量h中。。但是a的值变为null。。有人能帮我把值从for循环中传递出来吗?

string imageFileName = App.imagePath;
string a;
object b;
sting h;
int i;
string noteSeparate;
private void Library_Loaded(object sender, RoutedEventArgs e)
{

    if (MainListBox.Items.Count == 0)
    {
        //To save the separated note by '^'
        string[] noteSeparated;
        //Read the file and display it line by line.
        IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
        //Read the note saved in myFile.txt
        StreamReader readFile = new StreamReader(new IsolatedStorageFileStream("ViewFolder\myFile.txt", FileMode.Open, myStore));
            try
            {
                String fileText = readFile.ReadLine();
                //noteSeparated is the variable that save the retrieve note from myFile.txt and is noteSeparated by '^'
                noteSeparated = fileText.Split(new char[] { '^' });
                for (i = 0; i < noteSeparated.Length; i = i + 3)
                {
                  noteSeparate = noteSeparated[i];
                  a = noteSeparate;
                }
                h = a;
                readFile.Close();
            }
            catch (Exception)
            {
                noNoteBlock.Visibility = Visibility.Visible;
            }
        }

您应该放一个break;子句;。

最新更新