|
I am having a little bit of trouble trying to copy part of a 2d array to 1d.
In c/c++ i am using memcpy( OutBuff[pathId], writeBuff, writeLen );
In c# i am trying to use System.Array.Copy(writeBuff, OutBuff[pathId], writeLen);
The compiler doesn't seem to like this and i have searched for an answer but cant come up with anything.
Thanks for any help.
|
|
|
|
|
jollygiant wrote: The compiler doesn't seem to like this
So what does it tell you? It is not possible for us to guess what diagnostic messages appear on your screen.
It's time for a new signature.
|
|
|
|
|
The compiler reports
Argument 2: cannot convert from 'byte' to 'System.Array'
Here is the definition of OutBuff
private byte[,] OutBuff = new byte[MAX_PLCS,MAX_BUFF_SIZE+2];
Here is the function where used
public int writeBlock(byte path, byte [] writeBuff, int writeLen)
{
System.Array.Copy(writeBuff, OutBuff[path], writeLen); // <---- error line
|
|
|
|
|
Your function definition takes a byte array (writeBuff ) as its second parameter but you refer to OutBuff in your call to Copy . The line:
System.Array.Copy(writeBuff, OutBuff[path], writeLen);
should read something more like
System.Array.Copy(writeBuff, writeBuff??, writeLen);
although I suspect your parameters need refining.
It's time for a new signature.
|
|
|
|
|
The following seems to work:
System.Array.Copy(writeBuff, OutBuff, writelen);
The only question remaining is how to point the source to the correct offset of the 2D array. I suspect using the version of copy that takes offset values for source and destination.
Interesting problem though - any expert Csharpers who can comment?
It's time for a new signature.
|
|
|
|
|
OK third time lucky(er) ...
I discovered that Array.Copy requires both arrays to have the same number of dimensions. Also to copy from any point beyond the first element, e.g. starting in the next dimension, can only be done by using offsets. Thus the following sample is the way to go:
byte[,] OutBuff = new byte[3, 3];
byte[,] writeBuff = new byte[,]{ {1,2,3}, {0,0,0} };
System.Array.Copy(writeBuff, OutBuff, 2);
int offset = OutBuff.GetLength(0);
System.Array.Copy(writeBuff, 0, OutBuff, offset, 2);
Incidentally I just took a look in Charles Petzold's reference .NET book Zero[^] and he comments that:
Multidimensional arrays seem to be less common in object-oriented programming than in traditional procedural programming. It‘s probably more common in object-oriented programming to have single-dimensional arrays of objects, where the objects themselves encapsulate multiple items.
It's time for a new signature.
|
|
|
|
|
Thanks for your time and effort, i will give this a go on Monday.
|
|
|
|
|
You're welcome, it was a good learning exercise for me as well.
It's time for a new signature.
|
|
|
|
|
The charts look very messy when used with the database, so we need to modify the query to narrrow what info is displayed. Currently it is showing all of the information and it is too crowded. so How To Make it Clearer?
|
|
|
|
|
Is there any solution to record Skype conversation with C#.NET for both incoming and outgoing voice in one file?
|
|
|
|
|
Does anyone knows a grammar checker made in C#..
a class or library will do..
thanks
|
|
|
|
|
Do you want to write a compiler?
|
|
|
|
|
A grammar checker must be specific for a language, you cannot use an English grammar checker for Chinese texts and vice versa.
I would try to use the grammar checker of MS Word, that should be possible also from a C# application.
|
|
|
|
|
I have in place an application that sends faxes using a single modem card loaded on a server. I am installing a second modem card on the server and I was wondering if anybody out there knows how it will effect my current coding. I am trying to allocate traffic to both cards, is that done automatically by windows? How will the statuses be reported?
Please help as I can't find any information or manual that explains this.
Thank you in advance
Sameer
|
|
|
|
|
Years ago I had a server (WindowsNT) with 8 serial ports installed, one of them being connected to a modem. The fax software required that I assign a specific port to use; it would not allocate ports even if I had modems connected to several different ports.
Since then I've had Windows 2000, 2003, and 2008 Servers, and I don't recall any of them supporting modem pooling. That doesn't imply necessarily that they don't - I've never really looked for it before. But I think I would have seen some mention of it by now. The RRAS function would do this, but not the built-in Fax function.
If you'd like to tackle this as a project, it would make for an interesting article!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi Everyone
Can anyone tell me about IAX scripting. what is it? and can it be used in the communication of client and server?
I have done the client-server programming in C#.Both the programs are running individually but how can i communicate the client with server and vice verse.I mean how the connection between them is established?? Kindly guide me.!!
Regards,
|
|
|
|
|
Seems to be quite a few resources [^] out there. Did you try researching it. Oh you may want to try spelling it correctly, Google is good but not telepathic. Or have I found completely the wrong info?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
yeah you are right , it is AIX, someone told me wrong that it is IAX.. any ways thankyou
|
|
|
|
|
Hi this has probably been asked before but i am experiencing difficulties with the following error i encountered while creating a custom user control, it also prevents the form from appearing at design time:
Warning 1 ResX file Object of type 'TabHeadingControl.IPage[]' cannot be converted to type 'TabHeadingControl.IPage[]'. Line 185, position 5. cannot be parsed. 185 0
I cannot work out what is going wrong or where this message is originating
Thanks in advance George
|
|
|
|
|
I've had a similar message (for different controls) in a User Control. It turned out to be a scoping issue. Post a bit of your code and let us take a look at it.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I dont know why but it seemed to have repaired itself overnight, i cant get the error to re occur which is odd. Will keep an eye and post the source if it makes another apperance.
Thanks for the help
George
|
|
|
|
|
I've had that happen several times!
Spend most of a late night trying to find a bug in what looks like perfect code, give up and shut VS down for the night, then reopen the project the next day to find the bug has gone missing. If it helps, I've never had one of those "missing bugs" return later. If quitting fixes it, it stays fixed.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hello Everybody,
I am creating a app to convert Image to Text file. I refereed following link []. I am able to convert Image to text file.But when i convert Image file which have row and column layout (i.e., data is as in excel sheet format).when i read this type of file if the gap between corresponding columns is different. OCR takes it as Row delimiter and cuts the following text on new line. So I wanna replace the gaps to equal space while performing OCR scanning. Please help Any suggestions appreciated.
Regards
Rizwan
|
|
|
|
|
If you get the data into a text file then you can replace the char(9) tab in the text with char(34) which is a space, then output the text into the excel file.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello Mycroft Holmes,
When the data is retrieve in text file the order of rows and columns changes hence ,when i replace space with tab in Text file. I do not get the required table layout as in image file. Therefore i wanna replace it at the time of OCR scanning or know is there any alternative to achieve it. Any suggestion appreciated.
Regards
Rizwan
|
|
|
|