Struct Layout in C# to Delphi.Net

M

MuZZy

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
 
J

Jon Skeet [C# MVP]

MuZZy said:
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.
 
M

Marc Scheuner [MVP ADSI]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top