I have been trying to create this console application on C#.NET but I get this error message:
Error 1 Expected class, delegate, enum, interface, or struct
I’m new to C#, I did C++ before.
MAIN FILE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public void Main(string[] args)
{
string repositories = args[0];
string transaction = args[1];
var processStartInfo = new ProcessStartInfo
{
FileName = "svnlook.exe",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = String.Format("log -t \"{0}\" \"{1}\"", transaction, repositories)
};
var p = Process.Start(processStartInfo);
var s = p.StandardOutput.ReadToEnd();
p.WaitForExit();
if (s == string.Empty)
{
Console.Error.WriteLine("Message must be provided");
Environment.Exit(1);
}
Environment.Exit(0);
}
Every method in C# must be contained within a
classorstruct. There’s no way to define free-standing (“top level”) functions in C#.Try:
And an extra
}at the end.If you’re coming from a C++ background, as you indicate, you also shouldn’t assume that
structandclasshave the same similarities and differences as in C++.