Using Accessibility Modifiers on Auto Properties(codethinked.com)

submitted by justin_etheredgejustin_etheredge(8539) 2 years, 5 months ago

It may seem obvious to many, but yes, you can use accessibility modifiers on properties!

3 comments |category: |Views: 12

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by powerrushpowerrush(3873) 2 years, 5 months ago 0

Now we just need Auto Implemented Properties "null default value" settings. For instance, for a string property that is null, default to String.Empty. Something like:

public string FirstName { get default String.Empty; set; }

To do this otherwise you have to revert to a backing store.

Reply

posted by johnsheehanjohnsheehan(4785) 2 years, 5 months ago 0

Or set the default in the constructor.

Reply

posted by powerrushpowerrush(3873) 2 years, 5 months ago 0

Yes, but if the field is later set to NULL, then the only option (that I know of) is to have a normal property such as:

get { return _FirstName ?? String.Empty; }

Reply

information Login or create an account to comment on this story