c# - Use variable from the method -


how can call string[] phpcorrect out of method? if there's easy solution such of easy, share , if there method closer windows.storage.fileio.readtextasync, share it.

public async void readfile() {     // settings     var path = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php1.txt";     var path1 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php2.txt";     var path2 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php3.txt";     var path3 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php4.txt";     var path4 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php5.txt";     var path5 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php6.txt";     var path6 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php7.txt";     var path7 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php8.txt";     var path8 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php9.txt";     var path9 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php10.txt";     var path10 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php11.txt";     var path11 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php12.txt";     var path12 = @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php13.txt";     var path13= @"f:\designe- video\projects\phpgonehelp\phpgonehelp\phpcode\php14.txt";      var folder = windows.applicationmodel.package.current.installedlocation;      // acquire file     var file = await folder.getfileasync(path);     var file1 = await folder.getfileasync(path1);     var file2 = await folder.getfileasync(path2);     var file3 = await folder.getfileasync(path3);     var file4 = await folder.getfileasync(path4);     var file5 = await folder.getfileasync(path5);     var file6 = await folder.getfileasync(path6);     var file7 = await folder.getfileasync(path7);     var file8 = await folder.getfileasync(path8);     var file9 = await folder.getfileasync(path9);     var file10 = await folder.getfileasync(path10);     var file11 = await folder.getfileasync(path11);     var file12 = await folder.getfileasync(path12);     var file13 = await folder.getfileasync(path13);     var file14 = await folder.getfileasync(path13);      string[] phpcorrect = { await windows.storage.fileio.readtextasync(file),                             await windows.storage.fileio.readtextasync(file1),                             await windows.storage.fileio.readtextasync(file2),                             await windows.storage.fileio.readtextasync(file3),                             await windows.storage.fileio.readtextasync(file4),                             await windows.storage.fileio.readtextasync(file5),                             await windows.storage.fileio.readtextasync(file6),                             await windows.storage.fileio.readtextasync(file7),                             await windows.storage.fileio.readtextasync(file8),                             await windows.storage.fileio.readtextasync(file9),                             await windows.storage.fileio.readtextasync(file10),                             await windows.storage.fileio.readtextasync(file11),                             await windows.storage.fileio.readtextasync(file12),                             await windows.storage.fileio.readtextasync(file13)                            };     } 

how can call string[] phpcorret out of method ?

do mean want return value? this:

public async task<string[]> readfile() {     // code have      return phpcorrect; } 

now consuming code can use value:

var phpcorrect = await readfile(); 

note fixes fact you're using async void really shouldn't do. async method should @ least return task can awaited. otherwise errors within method can't observed, nor there way guarantee method completed.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -