.Net Code Monkey RSS 2.0
 Thursday, September 02, 2010

Mixed Scope Properties in .Net

There may be a time when you want to have mixed scope for your "Getters" and "Setters" in a property. For those of you who are not familiar with the syntax here it is

VB:

Public Property MyProperty as String
    Get
        Return _myField
    End Get
    Private Set
        _myField = Value
    End Set
End Property

This example allows a public "Getter" and a private "Setter".

The same can be done in C#:

public string MyProperty
{
    get { return _myField; }
    private set { _myField = value; }
}

Hope you find that useful.

Regards,

Dib.

Thursday, September 02, 2010 6:06:44 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.Net | Asp.Net | C# | Scope | VB Script
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Blogroll
 Clemens Vasters
 Harry Pierson
Passion * Technology * Ruthless Competence
 Joshua Flanagan
A .NET Software Developer
 Michael Schwarz's Blog
Developing applications on the Microsoft platform since Windows 3.1!
 Omar Shahine
Yet another Microsoft blogger
 Scot GU
Scott Guthrie lives in Seattle and builds a few products for Microsoft
 Scott Hanselman
Programming Life and the Zen of Computers
 Tom Mertens
Tom's corner
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Duane Wingett
Sign In
Statistics
Total Posts: 39
This Year: 4
This Month: 0
This Week: 0
Comments: 39
Themes
Pick a theme:
All Content © 2012, Duane Wingett
DasBlog theme 'Business' created by Christoph De Baene (delarou)