What does this error mean in C#? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What does this error mean in C#?

Error CS1022 : Type or namespace definition or end-of-file expected. What does this error mean?

4th Nov 2018, 6:23 AM
Kavish Bamboli
Kavish Bamboli - avatar
5 Answers
+ 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.
4th Nov 2018, 12:46 PM
Paul
Paul - avatar
+ 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.
4th Nov 2018, 1:14 PM
Paul
Paul - avatar
+ 3
I think this question is more easy to answer if we can run the code that produces the error.
4th Nov 2018, 7:31 AM
Paul
Paul - avatar
4th Nov 2018, 11:10 AM
Kavish Bamboli
Kavish Bamboli - avatar
0
What is the change?
4th Nov 2018, 1:01 PM
Kavish Bamboli
Kavish Bamboli - avatar