AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Monday 7 December 2015

What are "get & set" syntax in c#?

"Get Set" is also called auto property in c#. Set is used to set value in variable or object & Get is used to Fetch value from object or variable. Before starting this you should aware about c# properties. Properties are named members of classes, structures, and interfaces. A property consists of 2 parts, a get and a set method, wrapped inside the property.

It can be understood by given example.

private string _somevariable;
public string SomeVariable
        return this._somevariable;
        this._somevariable= value;
The get method should return the variable, while the set method should assign a value to it. There should at least Get property must be defined.


Post a Comment

  • Popular Posts
  • Comments