473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Lets Try Again, Writing Properties

What does everybody think of the below:
==========================================
Writing Properties
In C# name the property name should "shadow" the private variable name
that it represents differing only by case; Colour and colour for
example. But this would only apply when the variable that the property
represents is private, otherwise case-insensitive languages like
Visual Basic would have trouble accessing two members inside the type.

It is not possible to "shadow" the property name in Visual Basic, as
the language is case-insensitive. So the private variable can have an
alternate name or an underscore at the beginning, e.g. _colour.

[C#]
public string Colour
{
get
{
return colour;
}
set
{
colour = value;
}
}

[Visual Basic]
Public Property Colour As String
Get
Return _colour ' Can't use colour VB is case-insensitive
End Get
Set(ByVal _colour As String)
Me._colour = _colour
End Set
End Property
Nov 16 '05 #1
3 2449
Rasika Wijayaratne <sc*****@hotmail.com> wrote:
What does everybody think of the below:
==========================================
Writing Properties
In C# name the property name should "shadow" the private variable name
that it represents differing only by case; Colour and colour for
example. But this would only apply when the variable that the property
represents is private, otherwise case-insensitive languages like
Visual Basic would have trouble accessing two members inside the type.
Yes - but you should at least *almost* never have non-private variables
anyway.
It is not possible to "shadow" the property name in Visual Basic, as
the language is case-insensitive. So the private variable can have an
alternate name or an underscore at the beginning, e.g. _colour.


Something like that, yes.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Rasika,
I've seen the following naming conventions for VB.NET:

Private _colour As Color
Private mColour As Color
Private m_colour As Color

With different variations on casing. I prefer the third "m_colour" as its
more distinctive, however as Jon stated, the variables are private, so as
long as you are consistent within your Project, Solution, Team, Department,
Organization. I don't think naming convention on private variables really
matters...

Hope this helps
Jay

"Rasika Wijayaratne" <sc*****@hotmail.com> wrote in message
news:2b**************************@posting.google.c om...
What does everybody think of the below:
==========================================
Writing Properties
In C# name the property name should "shadow" the private variable name
that it represents differing only by case; Colour and colour for
example. But this would only apply when the variable that the property
represents is private, otherwise case-insensitive languages like
Visual Basic would have trouble accessing two members inside the type.

It is not possible to "shadow" the property name in Visual Basic, as
the language is case-insensitive. So the private variable can have an
alternate name or an underscore at the beginning, e.g. _colour.

[C#]
public string Colour
{
get
{
return colour;
}
set
{
colour = value;
}
}

[Visual Basic]
Public Property Colour As String
Get
Return _colour ' Can't use colour VB is case-insensitive
End Get
Set(ByVal _colour As String)
Me._colour = _colour
End Set
End Property

Nov 16 '05 #3
> What does everybody think of the below:
==========================================
Writing Properties
In C# name the property name should "shadow" the private variable name
that it represents differing only by case; Colour and colour for
example. But this would only apply when the variable that the property
represents is private, otherwise case-insensitive languages like
Visual Basic would have trouble accessing two members inside the type.

It is not possible to "shadow" the property name in Visual Basic, as
the language is case-insensitive. So the private variable can have an
alternate name or an underscore at the beginning, e.g. _colour.

[C#]
public string Colour
{
get
{
return colour;
}
set
{
colour = value;
}
}

[Visual Basic]
Public Property Colour As String
Get
Return _colour ' Can't use colour VB is case-insensitive
End Get
Set(ByVal _colour As String)
Me._colour = _colour
End Set
End Property

I agree with all, but what was your question?

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Eddie | last post by:
I need to validate a text input field. I just want to say if user enters 93101 or 93102 or 93103 or 93105 or 93106 or 93107 or 93108 or 93109 or 93110 or 93111 or 93116 or 93117 or 93118 or...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
6
by: mark4asp | last post by:
Suppose I have the following code. It functions to randomly select a city based upon the probabilities given by the key differences in the associative array. . Eg. because the key difference...
32
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 *...
1
by: Tristan | last post by:
Hi, In my application I need to store pen objects in a file so they can be read in at a latter stage from the file to recreate the pen objects in memory. I'm currently doing this by hand,...
102
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality...
2
by: Nathan Sokalski | last post by:
I am an ASP.NET developer who would like to start learning about writing ASP.NET custom controls using VB.NET. I already have a reasonable amount of knowledge with making ASP.NET pages, and am...
97
by: Master Programmer | last post by:
Thinking of learning VB.NET? New programmer? Thinking of Moving over from VB 6.0? Read on friend, let me help you make a more informed decision......... Microsoft are a pathetic company,...
5
by: David Veeneman | last post by:
I'm opening a JPG file to read and write its EXIF properties. I'm using very simple code to open the file: myBitmap = new Bitmap(filePath); Reading and writing the properties is working fine,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.