Meeting the needs of your business from a distance

C# Properties

by Mark Shiffer 27. December 2007 23:19

Ran across this today and did not realize that it could be done. In C# you can apply a different accessibility modifier to the get or set method of a property than that of the overall property. The least restrictive modifier is placed at the property level and the more restrictive modifier is placed in front of the get or set. This would come in handy when you want the property to be public available for read, but restricted for write access.

public string Name

{

get { return name;}

protected set {name = value;}

}

Tags:

Research | Programming

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Copyright © 2001-2010 MS Consulting, Inc. All Rights Reserved.