-3
public static int Id { get; set; }

It does not show any error but what is the exact definition of this statement?

Ron Beyer
  • 11,003
  • 1
  • 19
  • 37

2 Answers2

0

What you're doing is to declare a property. From dotnetperls:

Property. On a class, a property gets and sets values. A simplified syntax form, properties are implemented in the IL as methods.

With properties, we create standard access points from external places. We access Name, not GetName(). This leads to simpler code. It provides data-binding features.

Zippy
  • 1,804
  • 5
  • 27
  • 36
-1

This statement indicates that you declare the getter and setter of int Id

Where you want to get or set the value of int id you can call like this id.get() & id.set() for set some value init.

HassanUsman
  • 1,787
  • 1
  • 20
  • 38
  • I apologize for rejecting your edit on the OP, but the ASP tag did not have anything to do with the question and the formatting of the code was perfectly fine. The only real change was some grammar with the word "showing", otherwise the question was formatted properly. – Ron Beyer Aug 10 '15 at 13:54
  • 1
    You don't call a property in C# using a get() or set() method... – HeW Aug 10 '15 at 13:54