0

WHY GET ERROR

using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { string postText = Console.ReadLine(); Post post = new Post(); post.text = postText; //here post.ShowPost(); } } class Post { private string text; public Post() { Console.WriteLine("New Post"); } //escribe un constructor aquí public void ShowPost() { Console.WriteLine(text); } public string text {get; set;} //and here //escribe una propiedad para el texto del miembro }

26th Jan 2022, 12:24 PM
Tal
Tal - avatar
2 Respuestas
+ 3
You don't need to declare this 👇 private string text; Cause you already have an auto-implemented property by the name 'text' which allows read & write. No need for a backing field for such properties.
26th Jan 2022, 12:34 PM
Ipang
+ 1
Thanks brouh
26th Jan 2022, 3:41 PM
Tal
Tal - avatar