carlosA
Nie ma nic gorszego niż stary dziad, który po latach niedotykania programowania wyobraził sobie, że jednak może sobie pisać programy w c#, co gorsza irytuje się bo właściwie nie wiem, jak zadać google trywialne pytanie. Do rzeczy, jest sobie program:
//wyciąłem using i inne niepotrzebne
ProcessStartInfo start = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/c wmic cpu get name",
UseShellExecute = false,
RedirectStandardOutput = true,
};
using (Process process = Process.Start(start))
{
using (var reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
Console.ReadLine();
}
}
no i ok to sobie działa, jednak chciałbym string result poza powyższą strukturą i nie mogę, dlaczego? (a inaczej -czego z podstaw nie zrozumiałem). Bardziej literalnie, chciałbym użyć result w dalszej części programu tj. np.
string result2 = result;
Console.Writeline(result);
kończy się to błędem The name 'result' does exist in the current context.
Jak zdefiniować tego stringa, aby mógł go używać nadal i czego nie rozumiem z podstaw?
//wyciąłem using i inne niepotrzebne
ProcessStartInfo start = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/c wmic cpu get name",
UseShellExecute = false,
RedirectStandardOutput = true,
};
using (Process process = Process.Start(start))
{
using (var reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
Console.ReadLine();
}
}
no i ok to sobie działa, jednak chciałbym string result poza powyższą strukturą i nie mogę, dlaczego? (a inaczej -czego z podstaw nie zrozumiałem). Bardziej literalnie, chciałbym użyć result w dalszej części programu tj. np.
string result2 = result;
Console.Writeline(result);
kończy się to błędem The name 'result' does exist in the current context.
Jak zdefiniować tego stringa, aby mógł go używać nadal i czego nie rozumiem z podstaw?
#whatever
