Windows phone 7 将for循环内部的值传递到for循环外部windows phone 7

Windows phone 7 将for循环内部的值传递到for循环外部windows phone 7,windows-phone-7,isolatedstorage,Windows Phone 7,Isolatedstorage,我试图得到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 (M

我试图得到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;
            }
        }
string imageFileName=App.imagePath;
字符串a;
对象b;
刺h;
int i;
字符串注释分离;
已加载专用无效库(对象发送器,路由目标)
{
if(MainListBox.Items.Count==0)
{
//以“^”分隔注释的步骤
字符串[]已分离;
//读取文件并逐行显示。
IsolatedStorageFile myStore=IsolatedStorageFile.GetUserStoreForApplication();
//阅读保存在myFile.txt中的注释
StreamReader readFile=新的StreamReader(新的IsolatedStorageFileStream(“ViewFolder\\myFile.txt”,FileMode.Open,myStore));
尝试
{
字符串fileText=readFile.ReadLine();
//noteSeparated是保存从myFile.txt检索注释的变量,用“^”分隔
noteSeparated=fileText.Split(新字符[]{'^'});
对于(i=0;i
您应该在分配a=notespected[i];;之后立即放置一个break;子句。

您是否检查了for循环是否执行?是的,循环执行了类似于……a=notespected[i]的方法;break;现在我可以得到值了..你能帮我做另一件事吗?我被卡住了..独立文件中的文本格式为“notetTitle^ note^ imagePath^ notetTitle^ note^ imagePath^..”以此类推..我只尝试检索所有noteTitle。对于For循环内的变量a,我得到0,3,…但是对于For循环外的变量a,我返回空值(6)。可以帮助我仅获取所有noteTitle吗?使用上述代码使用列表累积值。您将需要两个嵌套循环。确保让我们知道我们在完成作业时的得分情况。此答案给予@kanchirk分数,并单独发布您的其他问题(使用更新的代码).很难用注释中的代码回答问题。