Click here to Skip to main content
15,889,527 members
Home / Discussions / C#
   

C#

 
GeneralRe: Avarage function in C#? Pin
riced25-Jun-10 1:05
riced25-Jun-10 1:05 
GeneralRe: Avarage function in C#? Pin
Pete O'Hanlon25-Jun-10 1:28
mvePete O'Hanlon25-Jun-10 1:28 
QuestionCopy Portion of 2d Array to 1d Array c# Pin
jollygiant24-Jun-10 21:31
jollygiant24-Jun-10 21:31 
AnswerRe: Copy Portion of 2d Array to 1d Array c# Pin
Richard MacCutchan24-Jun-10 23:29
mveRichard MacCutchan24-Jun-10 23:29 
GeneralRe: Copy Portion of 2d Array to 1d Array c# Pin
jollygiant25-Jun-10 0:18
jollygiant25-Jun-10 0:18 
GeneralRe: Copy Portion of 2d Array to 1d Array c# Pin
Richard MacCutchan25-Jun-10 3:44
mveRichard MacCutchan25-Jun-10 3:44 
GeneralRe: Copy Portion of 2d Array to 1d Array c# Pin
Richard MacCutchan25-Jun-10 4:10
mveRichard MacCutchan25-Jun-10 4:10 
GeneralRe: Copy Portion of 2d Array to 1d Array c# Pin
Richard MacCutchan25-Jun-10 4:55
mveRichard MacCutchan25-Jun-10 4:55 
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:
C#
byte[,] OutBuff = new byte[3, 3];
byte[,] writeBuff = new byte[,]{ {1,2,3}, {0,0,0} };

// copy the first two elements from writeBuff to OutBuff
System.Array.Copy(writeBuff, OutBuff, 2);

// get the offset to the second rank
int offset = OutBuff.GetLength(0);
// copy the first two elements of writeBuff to the second rank of OutBuff
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.

GeneralRe: Copy Portion of 2d Array to 1d Array c# Pin
jollygiant25-Jun-10 9:17
jollygiant25-Jun-10 9:17 
GeneralRe: Copy Portion of 2d Array to 1d Array c# Pin
Richard MacCutchan25-Jun-10 9:41
mveRichard MacCutchan25-Jun-10 9:41 
QuestionA problem about Crystal Reports .... Pin
milestanley24-Jun-10 20:51
milestanley24-Jun-10 20:51 
QuestionSkype Conversation Record Pin
Iftekher Developer24-Jun-10 19:12
Iftekher Developer24-Jun-10 19:12 
QuestionC# Grammar Checker Pin
maryannerose24-Jun-10 17:30
maryannerose24-Jun-10 17:30 
AnswerRe: C# Grammar Checker Pin
yu-jian27-Jun-10 9:12
yu-jian27-Jun-10 9:12 
AnswerRe: C# Grammar Checker Pin
Bernhard Hiller27-Jun-10 23:07
Bernhard Hiller27-Jun-10 23:07 
Questionfaxcomexlib and multiple fax modem cards Pin
Saamir24-Jun-10 6:13
Saamir24-Jun-10 6:13 
AnswerRe: faxcomexlib and multiple fax modem cards Pin
Roger Wright24-Jun-10 16:50
professionalRoger Wright24-Jun-10 16:50 
QuestionIAX/IAX2 protocol scripting ?? Pin
yum 201024-Jun-10 6:08
yum 201024-Jun-10 6:08 
AnswerRe: IAX/IAX2 protocol scripting ?? Pin
Mycroft Holmes24-Jun-10 12:14
professionalMycroft Holmes24-Jun-10 12:14 
GeneralRe: IAX/IAX2 protocol scripting ?? Pin
yum 201026-Jun-10 6:47
yum 201026-Jun-10 6:47 
QuestionResX error Pin
gwithey24-Jun-10 5:07
gwithey24-Jun-10 5:07 
AnswerRe: ResX error Pin
Roger Wright24-Jun-10 16:54
professionalRoger Wright24-Jun-10 16:54 
GeneralRe: ResX error Pin
gwithey24-Jun-10 21:32
gwithey24-Jun-10 21:32 
GeneralRe: ResX error Pin
Roger Wright25-Jun-10 2:43
professionalRoger Wright25-Jun-10 2:43 
QuestionHow to replace tab with space while performing OCR scan using MODI 11.0? Pin
mdrizwan_124-Jun-10 4:57
mdrizwan_124-Jun-10 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.