Invalid token in class struct or interface member declaration in c#

5.9k Views Asked by At

I have searched for this, but I can't seem to fix my code still.

I am learning C# and watching a tutorial, my code is identical to the video, but I get errors, when the video code works perfect, can anyone see anything wrong with my code?

I am using Visual Studio 2013 if that makes any difference at all.

All it does is call in a file, read it and display the text in a Console window.

I get the following errors: Invalid token '(' in class struct or interface member declaration Invalid token '=' in class struct or interface member declaration Invalid token '{' in class struct or interface member declaration

Error 10 'ConsoleApplication4.Program.inpFile' is a 'field' but is used like a 'type'

Thanks for any help, Adam P.S - Sorry for being such a newb...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            LoadFile();
        }
        private static void LoadFile();
    {
        StreamReader inpFile = null;
        inpFile = File.OpenText("../../well.txt")
        Console.WriteLine(inpFile.ReadToEnd());
    }


    }
}
1

There are 1 best solutions below

0
On

The problem in the following lines:

private static void LoadFile();


inpFile = File.OpenText("../../well.txt")

write:

 private static void LoadFile()
 inpFile = File.OpenText("../../well.txt");