C
C#8mo ago
Salty

WriteLine happening after Readline, why?

if (!file[i].Contains("Breakthrough pressure") & headerLine == 1 & dataStop == 0 & i - 2 > header_i)
{
//Console.WriteLine("found");
sw.WriteLine(Regex.Replace(file[i].Trim(), @"\s+", ","));
var plot_x = Regex.Replace(file[i].Trim(), @"\s+", ",").Split(",");

string ok = plot_x[0];
Console.WriteLine(ok);
Console.ReadLine();
if (!file[i].Contains("Breakthrough pressure") & headerLine == 1 & dataStop == 0 & i - 2 > header_i)
{
//Console.WriteLine("found");
sw.WriteLine(Regex.Replace(file[i].Trim(), @"\s+", ","));
var plot_x = Regex.Replace(file[i].Trim(), @"\s+", ",").Split(",");

string ok = plot_x[0];
Console.WriteLine(ok);
Console.ReadLine();
8 Replies
Salty
SaltyOP8mo ago
My ReadLine is getting called first after that i get the writeline why is that i dont see a reason to need async in here ?
Salty
SaltyOP8mo ago
No description
No description
Salty
SaltyOP8mo ago
seems my variables are empty when writeline is called but they are fine after the readline Im lost
await Task.Run(() =>
{
plot_x = Regex.Replace(file[i].Trim(), @"\s+", ",").Split(",")[0];
});
await Task.Run(() =>
{
plot_x = Regex.Replace(file[i].Trim(), @"\s+", ",").Split(",")[0];
});
doesnt help either
SleepWellPupper
SleepWellPupper8mo ago
I don't see WriteLine happening before ReadLine. The breakpoint on WriteLine was clearly hit? Where would that be? Seems to me your file[i] simply doesn't contain any data. So ok will be empty after calling Split. Could you check that file[i] actually contains a string that would result in the expected value for ok
Salty
SaltyOP8mo ago
but im getting data in writeline after the readline @SleepWellPupper i dont understand why its getting populated/printed out only then im also outputing data into a txt with sw.WriteLine(Regex.Replace(file[i].Trim(), @"\s+", ","));, and it is not blank
SleepWellPupper
SleepWellPupper8mo ago
Is this a single file in a console application? If so, I could take a look at it if you post a gist, repo or the file in here
Anchy
Anchy8mo ago
try splitting your lines up into individuals variables so you can properly track the state of everything when you set a breakpoint like what does file[i] even return, maybe follow the DRY principle instead of using file[i].Trim() multiple times I am also unsure if you are meaning to use the bitwise & operator in your if statement or the logical && operator
SleepWellPupper
SleepWellPupper8mo ago
Yeah the bitwise & is sketchy too
Want results from more Discord servers?
Add your server