473,769 Members | 7,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1655
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
2821
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 transform_signal; bool only_solid; bool line_as_solid; bool no_texture;
5
2599
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
2077
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 parameter. What would I need to do in order to convert a struct that looks like this: typedef struct { char rsvd0; char iadl1;
2
1275
by: mario.demiguel | last post by:
Does the standard support structs have constructors?
5
348
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 the struct, and populate them with data. 3) cin 1, 2, 3, or 4 from the user 4) If the user selected, say, 2, display the contents of the 2nd data
61
3781
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 (myBranch + x) = new Branch(i); // it doesn't x is a loop iterator, i is an int for the constructor to define an array. What am I doing wrong here.
7
2255
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
2532
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 using function pointers, but when I do, I cannot figure out how to get access to the member variables. Here is what I have so far: typedef struct { int board; void (*toString)(); void (*clear)();
29
2792
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 overhead (I think). A Struct seems more appropriate. At least it is what I would have used in other languages. But since a Struct *can* hold methods, I wander if I am saving anything. If not, why use it?
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.