如何解决将for循环内的值传递到for循环Windows Phone 7的外部
| 我正在尝试获取for循环内变量a的值。 对于下面的代码,我试图将值输入变量h。 但是a的值变为空。 谁能帮助我将值从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;
}
}
解决方法
你应该休息一下;子句在分配= = NoteSeparated [i];之后立即出现。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。