Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2007

Tip: Looking for answers? Try searching our database.

CLI ref structs and inheritance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaTurk - 07 Jun 2007 15:22 GMT
Hi,

I'm writing a CLI layer into my application, and I have several ref
structs.  Now, I've come into a situation that screams for a common
interface, but because the structs are ref, I didn't see a reason why
I couldn't have the structs implementing this interface.  ANd it does
work, but I'm concerned about the reprecussions of doing this.  Is
this good programming practice?  And what will the resulting struct
translate to in c#.  I mean it is a ref struct, so I would imagine it
would be what, a boxed something?  Oh, and before you ask, the reason
I haven't converted these objects to classes is just because it would
take a very large change in the design of the application which is
quite large at this point.  Please advise.

Thanks in advance.
Tamas Demjen - 07 Jun 2007 17:34 GMT
> I'm writing a CLI layer into my application, and I have several ref
> structs.  Now, I've come into a situation that screams for a common
> interface, but because the structs are ref, I didn't see a reason why
> I couldn't have the structs implementing this interface.  ANd it does
> work, but I'm concerned about the reprecussions of doing this.  Is
> this good programming practice?

Apart from the fact that by default struct members are public and class
members are private, a ref struct is identical to a ref class. If you
explicitly set the visibility (to public, private, protected, or
internal), they work the same way and generate the same code.

> And what will the resulting struct translate to in c#.

No, ref class and ref struct both translate to C# class. value class and
value struct both translate to C# struct.

> I mean it is a ref struct, so I would imagine it
> would be what, a boxed something?

Nope, ref struct is not a value type, it doesn't get boxed. It's a
reference type, a C# class.

Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.