|
Well that means that my effort to replace the < and others with the character was a big waste of time. Oddly, it appears correct for me: the correct characters are in the posting.
The FAQ doesn't mention PRE tags so hardware types like me will just gaze blankly at those words.
But let's try again. Rather than just copying and pasting the code into the Code Project window, I've saved it as a pure text file in hopes that will help. If not, I'll await instructions.
Chuck
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);
}
<REST OF FORM1 WAS DELETED>
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;
}
}
}
}
}
|
|
|
|
|
The FAQ may not discuss PRE tags, the sticky message "How to get an answer to your question" does.
And I forgot to tell you, under the edit box you'll find some checkboxes, the last one when checked, will cause whatever you paste to automatically adapt (i.e. replace < bY < and other such stuff).
You could clear and re-paste your code in your previous message...
|
|
|
|
|
Your problem is quite simple, but may take some thinking about. The reason you get the problem is because of this:
if (MemoryBank[j].bUsed == 1)
{
MemoryBank[i] = MemoryBank[j];
MemoryBank[j].bUsed = 0;
MemoryBank[i].bUsed = 1;
}
If you try the following smaller code fragment, you will get the same result:
List<cTemp> ls = new List<cTemp>(10);
int i;
cTemp ct;
for (i = 0; i < 10; i++)
{
ct = new cTemp(i.ToString(), i);
ls.Add(ct);
}
ls[5] = ls[6];
ls[6].s = "Hello";
ls[5].i = 42;
for (i = 1; i < 10; i++)
{
Console.WriteLine("{0}:{1}", ls[i].s, ls[i].i);
}
class cTemp
{
public string s;
public int i;
public cTemp(string ss, int ii)
{
s = ss;
ii = i;
}
}
Why? Because the elements of the List are references rather than the specific variables. By assigning a different reference via the line
MemoryBank[i] = MemoryBank[j]; you are "throwing away" the previous reference to the instance of the class held in MemoryBank[i], and causing both MemoryBank[i] and MemoryBank[j] to "point" to the same instance of a CUserMem class. If you then alter the content of the instance via either reference [i] or [j] you will appear to alter both instances, because they are the same. This is difficult to describe without diagrams, but if you single step the example above through the debugger, you will see what I mean.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Griff:
I see exactly what you mean. Knowing that I am dealing with references rather than the actual values is the key, and I would not easily have discovered this as the code "looks correct".
I'll head off to do a bit of reading and Googling for the right way to solve this.
Thanks for the lesson - I bet this will prove to be a valuable piece of information in making the jump from C to C#.
Chuck
|
|
|
|
|
You are welcome!
The transition from C to C# isn't too bad once you realize that all classes are on the heap, and thus all class variables are effectively C pointers to variables without the "->" all over the place.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
I want to be able to know what is the fallback mechanism for a language, and do it in code.
for example: i have files that aren't resource files but are different for different cultures.
i want to search manualy for a culture directory according to my culture. and if i don't find it there, i want to search for the fallback culture and so on, till i get to the root directory if the culture isn't found.
My question is: how can i find the "next fallback" culture for a given culture, thru code.
Thanks,
Yanai
[SOLVED]
The CultureInfo class has a "Parent" property just for that
modified on Monday, August 31, 2009 7:28 AM
|
|
|
|
|
I am analysing data which contains several different object types and would like to get them in a single collection but need to keep them in order.
I could use a dictionary and lists of each type but it would be easier (and maybe quicker) if I could have a single collection of the objects as the order the lists are in the original data is important.
Any suggestions on a reasonable method?
Thanks.
Elaine
modified on Sunday, August 30, 2009 12:16 PM
|
|
|
|
|
object[] ? ArrayList ? List<object> ?
|
|
|
|
|
Thanks PB, I'm still learning about collections.
|
|
|
|
|
Collect items of the most specialized common type, Object[] or List<Object> would always work; if you have some intermediate base class, that would be even better. So for a drawing it could be Shape[] or List<Shape> where your shapes inherit from your base or abstract Shape class.
|
|
|
|
|
A good idea, the other method would be something akin to the MFC VARIANT type where the members are the class types I need to put in the list.
I'll try your suggestion first.
Thanks Luc.
|
|
|
|
|
NP
|
|
|
|
|
Hello,
i had a running UDP-Server, but had the problem, that only every second package coming on. So now i wanted to re-code it with Socket and not using the UdpClient.
If i want to receive a datagram with Socket.EndReceiveFrom(ar,ref ep) it doesn't works. I get a NullReferenceException (i think the "ep" is the problem), but if i use Socket.EndReceive(ar) it works well.
Here the code:
string szData;
IPEndPoint ipe = new IPEndPoint(IPAddress.Any, 0);
EndPoint ep = (EndPoint)ipe;
int len = parent.udp_listen.EndReceiveFrom(ar,ref ep);
szData = Encoding.ASCII.GetString(buffer, 0, len);
"parent.udp_listen" is the public UdpClient which is in another class.
So what's wrong... is there another possibility to find out who is the sender of the datagram? Because i need the IP Address and the sending-Port of the sender.
Thanks
|
|
|
|
|
Is there a job market in Aus for C#.net asp.net ???
Just curious ...
|
|
|
|
|
Is this the right section to post this ??
|
|
|
|
|
Well, where the hell would you post it ???
|
|
|
|
|
Probably in the Lounge[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
No, to my knowledge Australia is not allowed to use .NET, let alone C#. This is why Chris Maunder moved to Canada.
|
|
|
|
|
Well thats encouraging ...
|
|
|
|
|
hi.
i have webpage that contain textbox. here is textbox code:
<input name="cardtxt1" maxlength="4" id="cardtxt1" tabindex="1" class="txtform" onpaste="doNotPaste()" onfocus="getName(this);documentFocus('cardtxt1');" onkeypress="return check_KeyPress(this,2,'0123456789')" onkeydown="noCTRL(event);" onkeyup="nextTab(this, false);" autocomplete="off" style="width: 32px;" type="text">
and i want set textbox value by this command:
HTMLInputElement card = (HTMLInputElement)doc.all.item("cardtxt1", 0);
card1.value = Value;
but my problem is after DocumentCompleted there is no value in textbox. value assigned to textbox before it get focused and when textbox get focused value will be cleared in textbox. how can i assign value to textbox after it get focused ?
or can i remove focus on textbox ?
|
|
|
|
|
I'm get in stuck of deployment an desktop application. My app was compiled against .net 3.5. On machine that doesn't have .net 3.5, the setup has to download .net 3.5 before install the app. The problem is download .net 3.5 take close to an hour, then user might cancel installation process.
I already compiled my app against .net 3.5 client profile, but it still take 5-10 minutes to download and still let users go away.
I dont know if there's a way to embed .net class library into my desktop app, so it could run without .net frx, or could we compile the app into native code?
Please help me if you have answer
Thanks.
|
|
|
|
|
No. Just mention it in the documentation or download site or whatever so that potential users know that .net is required before they download your app.
Most Windows systems already have it, so I wouldn't be especially concerned.
|
|
|
|
|
Almost user have .net 1.1 or 2.0. Since my app used .net 3.5, they have to have close to 1 hour to download .net 3.5 which will let users go away...
|
|
|
|
|
But that's really none of your concern.
|
|
|
|
|
It's absolutely my concern
|
|
|
|