For some reason even though I have declared a string in Program.cs static and public, when I reference it in another class e.g. Class1.cs, it does not find it:
Program.cs
public static string fileName = "test.txt";
Class1.cs
XElement address = new XElement("PingResults",
new XElement("NameoFile", fileName),
new XElement("URL", test),
new XElement("Time", test2)
);
I have also tried using Class1.fileName, but no luck.. Any ideas?
You have defined
fileNamein the classProgram. Therefore you should access it viaProgram.fileName.Side note:
fileNamedoesn’t follow .NET naming standards. useFileNameinstead!