TypeCasting question ???

  • Thread starter Thread starter Serge calderara
  • Start date Start date
S

Serge calderara

Dear all,

I have Class1 which belongs to myAssemby1. Class1 contains
columns structure of a table database as follow:

Class MyCustomer

...... some functoin and variables
Class CustomTable

public ID as long
public Customer as string
public Name as string
end class

end class

then in another assembly I have the same type of
infomation but defined as follow

Class MyBestCustomer

....
end function

...... some functoin and variables
Class BestCustomTable

public ID as long
public Customer as string
public Name as string
end class

end class

How can I update both data class in one shot as following?

MyCustomer.CustomTable = MyBestCustomer.BestCustomTable

I get an error saying "Cannot convert type x to type y"

Do u have any idea or tips how can I perform this inseat
of filling up individuial fields

thnaks for your help
regards
 
Since you are using the same values in both classes, and
the MyBestCustomer class has methods that MyCustomer
class does not, I would change the MyBestCustomer class
as follows:
Assuming both assemblies are in the same project

Public MyBestCustomer
-> inherits MyCustomer

---and---
delete the following lines in MyBestCustomer class:

public ID as long
public Customer as string
public Name as string

this way all 3 variables for both classes are the same
and there is no need to update each seperately.

if possible, make the 3 variables in the MyCustomer class
as Protected instead of Public, to increase security in
your application

hope this helps
Darshan
 
Thanks for your answer...

Just to clarify a bit, those type class which identify table structure
as MyCustomer will be located in an assembly that will be reference
inside a broject.

Then I have make some test with your suggestion.

I have define MyCustomer variables as protected.
Then I have create class1 which inherits MyCustomer and must fill up
MyCustomer parameter like as follow:
ID=123
Customer="Pipe S.A"
Name="John"

I am actually not able to fill those parameter due to protected keyword
????

Then class 1 should pass those parameter to Class2, for that Class2 as
one contructor like :
new (param as MyBestCustomer.MyCustomer)

then from class1 I write:

dim myCust a new Class2(CLass1.MyCustomer)

How can I fill them up my parameter in class1 to be passed to calss2
then?

thanks for your answer
 
Back
Top