471,089 Members | 1,058 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

CLI ref structs and inheritance

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.

Jun 7 '07 #1
1 1546
DaTurk wrote:
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
Jun 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Kenny McCarty | last post: by
5 posts views Thread by Dirk Reske | last post: by
2 posts views Thread by mario.demiguel | last post: by
61 posts views Thread by Marty | last post: by
7 posts views Thread by Markus Svilans | last post: by
5 posts views Thread by Chris Lieb | last post: by
29 posts views Thread by Dom | last post: by

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.