473,324 Members | 2,356 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,324 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 1639
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kenny McCarty | last post by:
I am trying to create an array of structs and I am having problems adding the values into the structure itself. Here is the code: struct predefinedCaptureSetting { int buffer_signal; int...
5
by: Dirk Reske | last post by:
hello, I have following problem: I have a struct "MainStruct" now I want to build structs which all "starts" with MainStruct. struct1 { MainStruct var;
10
by: Angel | last post by:
I'm using several C functions (in a dll) that receive a struct as parameter. Since I'm doing it in C#, I assume I need to recreate the struct in C# in order to call the function with the required...
2
by: mario.demiguel | last post by:
Does the standard support structs have constructors?
5
by: sherifffruitfly | last post by:
Hi, I'm just learning cpp, and the exercise I'm working on is basically as follows: 1) Create a struct type with 4 members (char, char, char, int). 2) Create an array of, say 3 instances of...
61
by: Marty | last post by:
I am new to C# and to structs so this could be easy or just not possible. I have a struct defined called Branch If I use Branch myBranch = new Branch(i); // everything works If I use Branch...
7
by: Markus Svilans | last post by:
Hi, What is the difference between having a struct with constructors and methods versus a class? In many C++ examples online I have seen code similar to this: struct Animal { Animal()
5
by: Chris Lieb | last post by:
I am trying to create a "pseudo-class" using structs. Member variables seem easy enough to do. However, trying to implement member functions has led to nothing but frustration. I have tried...
29
by: Dom | last post by:
I'm really confused by the difference between a Struct and a Class? Sometimes, I want just a group of fields to go together. A Class without methods seems wrong, in that it carries too much...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.