Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
AnswerRe: c# Regex Help [modified] Pin
PIEBALDconsult30-Aug-09 16:45
mvePIEBALDconsult30-Aug-09 16:45 
Question[solved] Proper way to sort a List<> Custom objects Pin
Dwayner7930-Aug-09 10:37
Dwayner7930-Aug-09 10:37 
AnswerRe: Proper way to sort a List<> Custom objects Pin
Henry Minute30-Aug-09 10:42
Henry Minute30-Aug-09 10:42 
AnswerRe: Proper way to sort a List<> Custom objects Pin
DaveyM6930-Aug-09 11:08
professionalDaveyM6930-Aug-09 11:08 
AnswerRe: Proper way to sort a List<> Custom objects Pin
Luc Pattyn30-Aug-09 11:13
sitebuilderLuc Pattyn30-Aug-09 11:13 
AnswerRe: Proper way to sort a List<> Custom objects Pin
Luc Pattyn30-Aug-09 12:06
sitebuilderLuc Pattyn30-Aug-09 12:06 
GeneralRe: Proper way to sort a List<> Custom objects Pin
Dwayner7930-Aug-09 15:41
Dwayner7930-Aug-09 15:41 
QuestionC# List problem Pin
Charlesh330-Aug-09 9:50
Charlesh330-Aug-09 9:50 
I'm a hardware engineer trying to make my first C# program and admittedly my rusty C is only a partial help.

I do this in my form:

public partial class Form1 : Form
{
public class CUserMem
{
public UInt32 bUsed; // supposed to be a Boolean but occupies 4 bytes
public UInt32 nCFreqHz; // Center Frequency
public UInt32 nDemIdx; // demod index: 4 or 5
public UInt32 nDemBWIdx; // normally 3 for 6 kHz
public UInt32 nVBFBWHz; // user selected filter BW (3.63 is a normal choice)
public Int32 nVBFFcHz; // frequency offset of filter
public UInt32 aTime; // long (epoch time when memory was created)
public byte version; // 0 currently
public Byte[] extDC; // 3 bytes of external downconverter info
public Byte[] rsvd; // 4 bytes reserved
public char[] desc; // memory tag
}
List <cusermem> MemoryBank = new List<cusermem>(10);

public Form1()
{
InitializeComponent();

for (i = 0; i < 100; i++)
{
CUserMem TempCUserMem = new CUserMem();
MemoryBank.Add(TempCUserMem);
}
<clip the="" rest="">

I then read a file and successfully populate MemoryBank[0] to MemoryBank[99].

Later I try to pack the data by "defragging" it. Here's the code, with the problem described in the comments:


public void PackBank(decimal BankNumber)
{
for (i = 0; i < 100; i++)
{
if (MemoryBank[i].bUsed == 0)
{
for (j = i + 1; j < 100; j++)
{
if (MemoryBank[j].bUsed == 1)
{
MemoryBank[i] = MemoryBank[j];
MemoryBank[j].bUsed = 0;

// here, both the 9th and 10th memories (elements 8 and 9) are 0 while 0 to 7 are 1
MemoryBank[i].bUsed = 1;
// here, both the 9th and 10th memories are 1 and 0-7 continue to be 1
// a test using atime instead of bUsed shows the same problem
j = 100;
}
}
}
}

}


Apparently elements 8 and 9 of the array are being viewed as copies of each other. I assume this is true for any elements, not just 8 and 9.

Since I successfully populated the list with different values for those elements when I did my file I/O, why do I have a problem later when I try to write to them?


Chuck
AnswerRe: C# List problem Pin
Luc Pattyn30-Aug-09 10:25
sitebuilderLuc Pattyn30-Aug-09 10:25 
GeneralRe: C# List problem Pin
Charlesh330-Aug-09 12:37
Charlesh330-Aug-09 12:37 
GeneralRe: C# List problem Pin
Luc Pattyn30-Aug-09 12:44
sitebuilderLuc Pattyn30-Aug-09 12:44 
AnswerRe: C# List problem Pin
OriginalGriff30-Aug-09 21:27
mveOriginalGriff30-Aug-09 21:27 
GeneralRe: C# List problem Pin
Charlesh331-Aug-09 17:26
Charlesh331-Aug-09 17:26 
GeneralRe: C# List problem Pin
OriginalGriff31-Aug-09 21:36
mveOriginalGriff31-Aug-09 21:36 
Questionfinding .resx fallback culture thru code [modified] Pin
yanairon30-Aug-09 6:00
yanairon30-Aug-09 6:00 
Question[Answered] Creating a list/collection containing different object types [modified] Pin
Trollslayer30-Aug-09 5:24
mentorTrollslayer30-Aug-09 5:24 
AnswerRe: Creating a list/collection containing different object types Pin
PIEBALDconsult30-Aug-09 5:34
mvePIEBALDconsult30-Aug-09 5:34 
GeneralRe: Creating a list/collection containing different object types Pin
Trollslayer30-Aug-09 6:16
mentorTrollslayer30-Aug-09 6:16 
GeneralRe: Creating a list/collection containing different object types Pin
Luc Pattyn30-Aug-09 6:29
sitebuilderLuc Pattyn30-Aug-09 6:29 
GeneralRe: Creating a list/collection containing different object types Pin
Trollslayer30-Aug-09 6:54
mentorTrollslayer30-Aug-09 6:54 
GeneralRe: Creating a list/collection containing different object types Pin
Luc Pattyn30-Aug-09 10:26
sitebuilderLuc Pattyn30-Aug-09 10:26 
QuestionUDP - Server (EndReceiveFrom) doesn't work Pin
softwarejaeger30-Aug-09 5:16
softwarejaeger30-Aug-09 5:16 
QuestionJob market Aussie ??? Pin
UBX30-Aug-09 4:02
UBX30-Aug-09 4:02 
AnswerRe: Job market Aussie ??? Pin
Abhishek Sur30-Aug-09 6:29
professionalAbhishek Sur30-Aug-09 6:29 
GeneralRe: Job market Aussie ??? Pin
UBX30-Aug-09 9:08
UBX30-Aug-09 9:08 

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.