An Atomic property is an advantage of Property hiding from out side world. It will reduce the Declareation space.There one difficulty we faced while initilizing a property in the loading time itself.
This behavior is then repeated for all properties on the type. So doing the right thing requires significantly more effort than the brittle approach. It will be more help full for getting C# 6.0 comes to the rescue with a new feature called auto-property initializers . The auto-property initializer allows assignment of properties directly within their declaration. For read-only properties, it takes care of all the ceremony required to ensure the property is immutable. Consider, for example, the DoublePrint class in this example:
This behavior is then repeated for all properties on the type. So doing the right thing requires significantly more effort than the brittle approach. It will be more help full for getting C# 6.0 comes to the rescue with a new feature called auto-property initializers . The auto-property initializer allows assignment of properties directly within their declaration. For read-only properties, it takes care of all the ceremony required to ensure the property is immutable. Consider, for example, the DoublePrint class in this example:
Implementation
public class DoublePrint
{
public DateTime TimeStamp { get; } = DateTime.UtcNow;
public string User { get; } = System.Security.Principal.WindowsPrincipal.Current.Identity.Name;
public string Process { get; } =System.Diagnostics.Process.GetCurrentProcess().ProcessName;
}
----------------------------------Happy to doing....
No comments:
Post a Comment