+ 1
What does this error mean in C#?
Error CS1022 : Type or namespace definition or end-of-file expected. What does this error mean?
5 odpowiedzi
+ 6
Like this it seems to be working:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
class BankAcc
{
public void AccDetails(int bno, string name)
{ Bno = bno; // changes here
Name = name; }
public int Bno{ get; set; }
public string Name{ get; set; }
}
static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
string n1 = Console.ReadLine();
BankAcc a1 = new BankAcc();
a1.AccDetails(n, n1);
// changes in next two lines
Console.WriteLine(a1.Bno);
Console.WriteLine(a1.Name);
}
}
}
I moved one curly brace. and made changes where they are in comments.
+ 4
I think that public int Bno and public string Name should be part of class BankAcc, but not part of public void AccDetails, that was your error, I think. You made them part of AccDetails.
+ 3
I think this question is more easy to answer if we can run the code that produces the error.
0
What is the change?