|
-
Aug 31st, 2006, 09:51 PM
#1
Thread Starter
Fanatic Member
[2005] Question about writing a class
I'm working on a class using a tutorial and I'm wondering about something I'm seeing.
<vbcode>
<System.ComponentModel.DataObject()> _
Public Class ProductsBLL
Private _productsAdapter As ProductsTableAdapter = Nothing
Protected ReadOnly Property Adapter() As ProductsTableAdapter
Get
If _productsAdapter Is Nothing Then
_productsAdapter = New ProductsTableAdapter()
End If
Return _productsAdapter
End Get
End Property
End Class</vbcode>
Why all the underscores (_) ??
In the _productsAdapter declaration, why the underscore?
I'm confused.
Thanks!

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
-
Aug 31st, 2006, 10:03 PM
#2
Hyperactive Member
Re: [2005] Question about writing a class
Its just a good way to declare variables, easy to see and used as a standard in many shops
-
Aug 31st, 2006, 10:14 PM
#3
Thread Starter
Fanatic Member
Re: [2005] Question about writing a class
wow i've never seen it. So do I call my variables like that too?
thanks for the quick response!

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
-
Aug 31st, 2006, 10:21 PM
#4
Fanatic Member
Re: [2005] Question about writing a class
The _ usually indicates member vairables lots of microsoft people use the mixture of _ and m_variable.
-
Sep 1st, 2006, 05:00 AM
#5
Re: [2005] Question about writing a class
The first underscore is a line continuation.
Code:
<System.ComponentModel.DataObject()> _
Public Class ProductsBLL
means:
Code:
<System.ComponentModel.DataObject()> Public Class ProductsBLL
Using underscores in variable names is an old way of indicating private variables in a class.
-
Sep 1st, 2006, 08:58 AM
#6
Thread Starter
Fanatic Member
Re: [2005] Question about writing a class
 Originally Posted by mendhak
The first underscore is a line continuation.
Code:
<System.ComponentModel.DataObject()> _
Public Class ProductsBLL
means:
Code:
<System.ComponentModel.DataObject()> Public Class ProductsBLL
Using underscores in variable names is an old way of indicating private variables in a class.
Why have the namespace before the declaration of the class? I've never seen that before (before and after the line continuity)

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
-
Sep 1st, 2006, 11:43 AM
#7
Re: [2005] Question about writing a class
You're talking about the part in <> right? That's not a namespace, that's an attribute. It is a way of tagging up the function or class. This specific one tags the class as a 'dataobject'.
This means that an object of this class type can be bound to.
-
Sep 1st, 2006, 11:54 AM
#8
Thread Starter
Fanatic Member
Re: [2005] Question about writing a class
ohhh i see... kinda 
So your tagging the DataObject attribute to the class... i got that
But I'm not quite sure what you mean when you say "This means that an object of this class type can be bound to."
Here's a better example perhaps:
VB Code:
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, True)> _
Public Function GetProducts() As Northwind.ProductsDataTable
Return Adapter.GetProducts()
End Function

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
-
Sep 1st, 2006, 12:06 PM
#9
Re: [2005] Question about writing a class
For a DataObject class, the DataObjectMethodAttribute attribute would specify what it does, and whether it's the default method for that dataobject class.
About what I meant. You know about the dataset class. The dataset class can be bound to. The datagrid, when it binds to a dataset, will expect that the dataset knows what information it has, how to retrieve, update, manipulate it.
Similarly, there's your DataObject attributed-class. You're essentially creating a custom dataset specific to your application.
-
Sep 1st, 2006, 03:01 PM
#10
Thread Starter
Fanatic Member
Re: [2005] Question about writing a class
Excellent! That clears things up a bit!

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|