0
Why do public string Name {get; set;}?
class Person { public string Name { get; set; } public Person() { Console.WriteLine(name); } } static void Main(string[] args) { Person p = new Person(); p.Name = "Bob"; Console.WriteLine(p.Name); } // Yea why do that? it is exactly same as writing public steing Name; i think. Because if I want to print that " name" the compiler gives me error that "name" does not exist in current context.
6 odpowiedzi
0
What langauge is this?
0
Its C# Skrub
jeps997 That's encapsulation, mostly used when we require to process the variable before assign or return the variable.
0
But what Programming(s) is this?
0
langauge?
0
C#
0
Ah sorry cant help