473,473 Members | 2,232 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Struct Layout in C# to Delphi.Net

Hello,
Well, i am pretty new to c# and .NET overall.
I am trying to port a c# program to Delphi.NET, and can't figure out a few
things:

1. in C# they declare a const: const short = 1;
In Delphi you can't combine those, how do i port it?
2. [StructLayout(LayoutKind.Sequential, Pack=2)] It is placed before class
declaration. What the hack is that? And how i go about Delphi?

Any ideas would be highly appreciated!

Thank you,
Andrey
Nov 15 '05 #1
2 1568
MuZZy <le*******@yahoo.com> wrote:
Well, i am pretty new to c# and .NET overall.
I am trying to port a c# program to Delphi.NET, and can't figure out a few
things:

1. in C# they declare a const: const short = 1;
In Delphi you can't combine those, how do i port it?
2. [StructLayout(LayoutKind.Sequential, Pack=2)] It is placed before class
declaration. What the hack is that? And how i go about Delphi?

Any ideas would be highly appreciated!


I suggest you ask in a Delphi newsgroup rather than a C# one - that's
where people are more likely to know about Delphi. However, I also
suggest you phrase your question in terms of what you want to achieve,
not how it's achieved in C# - that means that people who don't know C#
will still be able to help you.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
>1. in C# they declare a const: const short = 1;

The same:

const
Short = 1;
2. [StructLayout(LayoutKind.Sequential, Pack=2)] It is placed before class
declaration. What the hack is that? And how i go about Delphi?


Same:

* add "System.Runtime.InteropServices" the the uses clause

[StructLayout(LayoutKInd.Sequential, Pack=2)]
TMyClass = class.......
......
end;

Remember: Delphi 8 for .NET *IS* a full featured .NET language - no
need to break or change stuff from C# - it uses the SAME foundations!

Marc
Nov 15 '05 #3

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

Similar topics

5
by: Kobu | last post by:
In embedded systems (programmed in C), often times structure declarations are used to group together several status/control/data registers of external hardware (or even internal registers). The...
8
by: Mike | last post by:
The following struct, DataStruct, is only part of a larger one that contains additional fields and arrays. I need the explicit layout because this struct is really a union, where some of the...
8
by: Ben Terry | last post by:
What's the most efficient way to transfer data from a byte to a struct? The struct is rather complex--contains other structs as well as byte members. I've tried to use Marshal.Copy and an IntPtr...
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
2
by: Jack Ukleja | last post by:
Hi guys, I'm trying to figure out a way to do reflection on structs which are in a legacy c++ header file. Basically I want to write a C++/CLI program that lets me edit the binary data in the...
3
by: Digital Fart | last post by:
I have the following function that returns a struct public struct layout { public string str; public int i; } function in some class where i loop through an arraylist of structs
3
by: Joanna Carter [TeamB] | last post by:
Hi struct MyStruct { int value = 64; // does not compile public MyStruct() { value = 64; //does not compile }
4
by: Michael Brennan | last post by:
I have a menu_item structure containing an union. func is used if the menu item should use a callback, and submenu if a popupmen should be shown. struct menu_item { enum { function, popup }...
12
by: Milux | last post by:
Hi All, This question has to do with interface design. Suppose I have an translation tool. It can translates structs from type "general" to other types and then does some processing. Example:...
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
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...
0
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,...
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...
1
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.