473,396 Members | 2,098 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,396 software developers and data experts.

A question about the same definition object in the different namespaces.

Hi, everyone,

I want to find a proper way to convert different object types in the
different namespaces.

such as

namespace A
{
class C
{
public string name;
public string address;
}
}

namespace B
{
class C
{
public string name;
public string address;
}
}

A.C ca = new A.C();

I want to like that B.C cb = (B.C) ca. but it is wrong!!!(Once I have
a more complex object definition).

I know that i can use XML serialization to convert it .LIKE use XSD to
generate class.

But can I have a elegant approach to do it?

Any suggestion will be welcome.

Sincerely,
simida

Aug 7 '06 #1
2 1792
Hello simida,

Yeah, don't duplicate class definitions. Just use one class.

-Boo
Hi, everyone,

I want to find a proper way to convert different object types in the
different namespaces.

such as

namespace A
{
class C
{
public string name;
public string address;
}
}
namespace B
{
class C
{
public string name;
public string address;
}
}
A.C ca = new A.C();

I want to like that B.C cb = (B.C) ca. but it is wrong!!!(Once I have
a more complex object definition).

I know that i can use XML serialization to convert it .LIKE use XSD
to generate class.

But can I have a elegant approach to do it?

Any suggestion will be welcome.

Sincerely,
simida

Aug 7 '06 #2
Yeah, I should keep interface isolation. I don't want others to read my
class directly.

namespaces resided in different projects. Although it duplicate class
definitions, Thay have different means in application logic lay. So, I
have to do this job for keeping interface isolation.

GhostInAK wrote:
Hello simida,

Yeah, don't duplicate class definitions. Just use one class.

-Boo
Hi, everyone,

I want to find a proper way to convert different object types in the
different namespaces.

such as

namespace A
{
class C
{
public string name;
public string address;
}
}
namespace B
{
class C
{
public string name;
public string address;
}
}
A.C ca = new A.C();

I want to like that B.C cb = (B.C) ca. but it is wrong!!!(Once I have
a more complex object definition).

I know that i can use XML serialization to convert it .LIKE use XSD
to generate class.

But can I have a elegant approach to do it?

Any suggestion will be welcome.

Sincerely,
simida
Aug 7 '06 #3

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
51
by: Casper Bang | last post by:
My question is fundamental I beleive but it has been teasing me for a while: I have two classes in my app. The first class is instantiated as a member of my second class. Within this first class,...
4
by: cr113 | last post by:
I can't seem to make sense out of the Object Browser in VB.NET. Here's one example. I often use the the Sleep method found in the Thread object like this: Imports System.Threading Private...
38
by: Arjang | last post by:
http://www.codeproject.com/useritems/CSharpVersusVB.asp
161
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.....
30
by: questions? | last post by:
say I have a structure which have an array inside. e.g. struct random_struct{ char name; int month; } if the array is not intialized by me, in a sense after I allocated a
4
by: Sean | last post by:
I am a little confused by the "extern inline and static inline" rules. I understand that "extern inline" guarantees no function storage is created (all are inlined). But the following test seems to...
18
by: Tom Cole | last post by:
I'm working on a small Ajax request library to simplify some tasks that I will be taking on shortly. For the most part everything works fine, however I seem to have some issues when running two...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.