473,840 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting array type

I'm converting some routines from C to C#. The code involves having arrays
of bytes which are passed to a function as an array of longs. Well,
technically the C code has a pointer to an array of char which is passed to
the function which treats the pointer as a pointer to an array of longs.

I would appreciate if someone could direct me to an example, article, etc.
that discuss how to convert such code to C#.

TIA,

Richard Rosenheim
Nov 15 '05 #1
2 2884
Richard,
I would appreciate if someone could direct me to an example, article, etc.
that discuss how to convert such code to C#.


The System.Buffer class is handy for doing memory copies between
arrays of simple integer types, I think that would be the best
solution.

In an unsafe context you can do the same as in C, get a pointer to the
array and cast it to some other pointer type. But I'd avoid it if
possible.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
Thanks. Not as efficient as just recasting the type, but it will do the
job.

Richard Rosenheim
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:Of******** ******@TK2MSFTN GP09.phx.gbl...
Richard,
I would appreciate if someone could direct me to an example, article, etc.that discuss how to convert such code to C#.


The System.Buffer class is handy for doing memory copies between
arrays of simple integer types, I think that would be the best
solution.

In an unsafe context you can do the same as in C, get a pointer to the
array and cast it to some other pointer type. But I'd avoid it if
possible.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 15 '05 #3

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

Similar topics

1
26969
by: jaYPee | last post by:
I have created a stored procedure that contain this field (below) in order to meet certain criteria. But my problem is when I try to run the stored procedure I encounter an error "Error converting data type varchar to float". CASE Final WHEN 0 THEN '--' ELSE Final END AS FinalGrade The Final field is a float data type. Could anyone teach me how to fix this problem?
6
4210
by: Eric Smith | last post by:
Is a structure containing an incomplete array as its last element (per paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an incomplete type? That appears to be indicated by paragraph 22 of section 6.2.5. If so, that seems to make it difficult to allocate such structures, because sizeof() is not allowed on incomplete types (paragraph 1 of section 6.5.3.4). For instance, I've routinely done things like this: struct foo {...
4
3165
by: Harris | last post by:
Does anyone know how to get the underlying type of an Array type? Here's a bit of code demonstrating what I'm looking for... public Type getUnderlyingType( Type arrayType ) { if( !arrayType.IsArray ) throw exception //get the underlying type and return it
1
9875
by: luna | last post by:
got so far then it broke and i cant get it working again - it was updating fine but not inserting and now im getting a "Error converting data type varchar to numeric" which i didnt have before.... stored procedure is CREATE Procedure newupdate @newid varchar(50), @newnews varchar(50)
4
2268
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it will work with a variable mutl- row, 5 column datatable where the users select items. Anyone have any suggestions on where to start? Or changes in the current code that might be made.
2
3025
by: Curious Trigger | last post by:
Hello, if have an asp.net web page with a detailsview. This detailsview uses a sqldatasource connecting to a sql server 2005 database with a select statement simliar to this one: SELECT warning_threshold, critical_threshold, weight FROM thresholds UPDATE thresholds SET warning_threshold=@warning_threshold, critical_threshold=@critical_threshold, weight =@weight I also added insert and delete statements to this datasource.
0
3471
by: bluepiper | last post by:
Hi everyone. I have created a linked server on SQL Server 2005 to access data from visual foxpro database. I execute a query Select * from OpenQuery(members, 'Select * from memfile') but Im getting an error message: error converting data type DBTYPE_DBTIMESTAMP to datetime. Why does this error occurs? Is it about getting null value from date type?? How can i retrieve the data from the query? Can anyone please help me or give me an example...
5
10825
by: =?utf-8?b?QXNiasO4cm4gU8OmYsO4?= | last post by:
For various reasons, I have a number of typedefs to name arrays of various sizes and for various purposes. I also have functions taking variables of such typedef-ed types as their input arguments. Now I want to feed one such function part of a larger array. To have the correct type in the call to the function, I am trying to use a cast. But I can not find a cast that does not produce warnings. See the line with the comment "Gives...
1
7901
by: ehsanch | last post by:
Hi i am writing a SOAP client, when using php 5 soap , it send this code and i get error : <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://magfa.com/soap/SOAPSmsQueue" xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"...
0
9702
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
10607
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...
1
10665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10302
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...
1
7845
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
5686
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4498
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 we have to send another system
2
4080
muto222
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.