Reputation: 13
I've tried to find a solution but found none.
The problem seems to be the public int number but I have no idea how to fix it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrimTal
{
class Program
{
public static void Main(string[] args)
{ // } expected
public int number;
number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ditt nummer är: " + number);
Console.ReadKey();
}
}
} // type or namespace definition, or end-of-file expected
Upvotes: 1
Views: 282
Reputation: 3631
Properties must be "outside", like this:
class Program
{
// Properties
public static int Number {get; set;}
// Methods
public static void Main(string[] args)
{
Number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ditt nummer är: " + Number);
Console.ReadKey();
}
}
Or you can use a local variable: int number = Convert.ToInt32(Console.ReadLine());
in Main
.
Upvotes: 1