Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between CSLA getproperty, setproperty and general getters and setters

I am new to C#, csla and NHibernate. This might be a novice question but I didn't see a clear explanation elsewhere. Can someone please help me in understanding what is the difference between

   public int Property
    {
        get { return GetProperty<int>(Property); }
        private set { SetProperty<int>(Property, value); }
    }

and

public int Property{get;set;}
like image 389
user2990315 Avatar asked Nov 01 '22 06:11

user2990315


1 Answers

CSLA implements a powerful new way of implementing properties, where you don't need to declare a field to store the property's value. The field values are managed by CSLA .NET and so are called managed fields. In the future some advanced features of CSLA .NET may be unavailable unless you use managed fields.

Syntax :

public string Name
{
  get { return GetProperty<string>(NameProperty); }
  set { SetProperty<string>(NameProperty, value); }
}

CSLA also supports a different syntax where you use private fields to store the values. This technique is faster than using managed fields, but requires that you declare and maintain your own fields.

Hope this gives a clear idea about the GetProperty and SetProperty

like image 195
Tharif Avatar answered Nov 15 '22 05:11

Tharif