Re: Delphi.NET
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Tue, 26 Jun 2007 19:04:45 -0500
Daniel Hobson wrote:
I was wondering if anybody is out there who uses Delphi.NET. We seem to be having a few problems in knowning
about the new requirements of DotNET. The main one that has us really stumped is how do you
convert from one data type to another different data type?
For example:-
Type
TTestRec = record
t1: array [1..32] of char;
t2: array [1..28] of char;
end;
MyBuffer : TidBytes;
MyActType : TTestRec;
I read in the information via TCP/IP into MyBuffer (Have no choice in the matter)
The question is now .. how can I say that MyBuffer is type TTestRec ????
You don't. That would by lying. You've clearly declared MyBuffer as a completely different type.
What you're trying to do is get the contents of the MyBuffer array into the MyActType record. That task is really trivial, so I suppose the unwritten part of your question is that you want to get the array contents into the record without actually having to write a loop yourself.
For that, you can use the System.Runtime.InteropServices.Marshal class. It has a Copy method overloaded to take lots of different parameter types.
--
Rob
.
- Follow-Ups:
- Re: Delphi.NET
- From: Daniel Hobson
- Re: Delphi.NET
- References:
- Delphi.NET
- From: Daniel Hobson
- Delphi.NET
- Prev by Date: Re: Delphi.NET
- Next by Date: Re: Delphi.NET
- Previous by thread: Re: Delphi.NET
- Next by thread: Re: Delphi.NET
- Index(es):
Relevant Pages
|