VB.Net Class Design Question
I've been working with a simple class library and a class that built. I was doing something that worked, but I broke it and now I cannot get it to work any longer. Some of the testing that I have been doing has shown me that I am missing something here, but I need to understand this. I think it is very simple, but I simply have never needed this before and I have not ran across in the past 4+ years of working in .Net.
Here's the basic idea.
Class Library contains a class, lets call it LOOKUP(). Lets say that the class is used for a phone book. The LOOKUP() method would have parameters to pass in such as that might be fname, mname, lname, address, city, state, zip, and phonenumber. Lets say that the class1 has a lookup mechanism where you can send in different parameters and the process will lookup the rest and return it to the calling code. That's sort of on the same level of what I am looking at in my app. It should be very simple.
However, I am doing something a little odd. I cannot return the data using a dataset, datarow, xml, etc. I need to return the same parameters of the method that go in. So I need to return the fname, mname, lname, address, city, state, zip, and phonenumber using the same names as used in the method's parameters.
Here's an example in VB.Net.
Public Function LookUp(ByVal fname As String, ByVal mname As String, ByVal lname As String, ByVal address As String, ByVal city As String, ...
What I did was to create properties for each of the these. Something like
Public Property fname() as string
Public Property mname() as string
Public Property lname() as string
This started to work, but then I realized that .Net was automatically hooking the property and the parameter up. So my guess is that there is a way that .Net can handle this, but I'm missing something.
Can someone point me in the right direction here? Does .Net handle this sort of thing for you? I want to call a method with a given set of parameters, then have those parameters be accessed after the method has exited. Setting up properties seems to the be correct way to do this, but .net sync'd them for me. So I did not have to set them equal to each other in the code, and I was able to use the same name for the properties and the parameter.
So my question is, did Microsoft set up something for this so the parameters and the properties could work together without having to do a lot of coding? It looks like they did, but I'm running into a few bugs with it. Are they supposed to automatically sync because they have the same name? That is what I want. I'm just hitting some bugs with this and I think I am setting up something incorrectly. What's the correct way to do this?
Any suggestions would be appreicated.
Last edited by jrothlander; 07-01-2006 at 06:03 PM.
Last Post: 07-09-2005, 07:50 AM
By Guillaume LagacÚ in forum ASP.NET
Last Post: 05-21-2002, 03:50 PM
Last Post: 03-28-2002, 08:14 AM
By Sandoval Gonzalez in forum VB Classic
Last Post: 11-09-2001, 05:29 PM
Last Post: 09-28-2000, 05:11 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center