[newbie] Converting structures

G

Guest

Hi

in my project, I make use of two namespaces and each of it uses the same structure (so that the same structure is defined two times). Now, when I try to call a function of the second namespace out of the first one, VB.NET throws a compiler error, saying that I can't convert from Proj1.namespace1.mystruct to Proj1.namespace2.mystruct - although it's just the same structure !!

Can anyone help me

Gordon
 
N

Nick Holmes

Its doesn't matter that the structures are the same (or even in two
different namespaces), type safety prevents this kind of conversion. If you
could readily convert (cast) between any two types with the same structure,
you would have a easy way to bypass application logic that contrained values
held in the type.

If you need to use the same structure in two places, one simple way would be
to put it in its own assemble, and use it whereever its needed.

Nick.

Gordon Knote said:
Hi,

in my project, I make use of two namespaces and each of it uses the same
structure (so that the same structure is defined two times). Now, when I try
to call a function of the second namespace out of the first one, VB.NET
throws a compiler error, saying that I can't convert from
Proj1.namespace1.mystruct to Proj1.namespace2.mystruct - although it's just
the same structure !!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top