将for循环中的值传递到for循环windows phone 7之外

时间:2011-06-25 14:55:04

标签: windows-phone-7 isolatedstorage

我试图获取变量a的值,它位于for循环中。 对于我的下面的代码,我试图将值变为变量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;
            }
        }

1 个答案:

答案 0 :(得分:0)

你应该休息一下;在指定a = noteSeparated [i];。

之后立即执行