473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

weird behavior

Given following code:

tasks = new StationTasks[stations.Length * configurations.Length];
int taskNr = -1;
for (int i = 0; i < stations.Length; ++i) {
foreach (Configuration conf in configurations) {
++taskNr; // line A
StationTasks st = new StationTasks( conf, stations[i]); // line B
tasks[taskNr] = st; // line C

ArrayList tasksRaw = getTasks(conf, stations[i].Col_ID.GetInt());
// determine max length
int lengthStation = 0;
foreach (TaskItem ti in tasksRaw)
lengthStation += ti.TotalLength;

if (lengthStation > maxLength)
maxLength = lengthStation;

if (modeGroup == ModesGroup.Solid) {
// ...

} else if (modeGroup == ModesGroup.Category) {

ArrayList categories = new ArrayList();
foreach (TaskItem ti in tasksRaw) {
string key = ti.MarkerLColor.ToArgb().ToString() + ":" + ti.MarkerRText;
if (!categories.Contains(key))
categories.Add(key);
}
foreach (string key in categories) {
int key_i = key.IndexOf(":");
int colorID = int.Parse( key.Substring(0, key_i) );
Color color = Color.FromArgb( colorID );
if (color.ToArgb() == 0)
color = Color.Empty;
string cat = key.Substring(key_i + 1);
if (cat == "")
cat = null;

int length = 0;
foreach (TaskItem ti in tasksRaw)
if (ti.MarkerRText == cat && ti.MarkerLColor.ToArgb() == colorID)
length += ti.TotalLength;

if (length > 0) {
TaskItem ti = new TaskItem(null, null, length, Color.White);
ti.MarkerLColor = color;
ti.MarkerRText = cat;
st.TaskItems.Add(ti); // line D
}
}
}
}
}

where:

private class StationTasks {

private Configuration configuration;

public Configuration Configuration {
get { return configuration; }
set { configuration = value; }
}
private Station station;

public Station Station {
get { return station; }
set { station = value; }
}
private ArrayList taskItems;

public ArrayList TaskItems {
get { return taskItems; }
}
public StationTasks(Configuration conf, Station station) {
this.configuration = conf;
this.station = station;
taskItems = new ArrayList();
}

}

(the contents of Configuration, Station, TaskItem, etc. is not necessary
here)

how is it possible that the above code works well, whereas changing the
marked lines:

lines A, B, C to:
tasks[++taskNr] = new StationTasks( conf, stations[i]); // line B
and line D to:
tasks[taskNr].TaskItems.Add(ti); // line D

causes the program to behave buggy? For instance, when taskNr == 1, line D
would call tasks[0].TaskItems.Add(ti) instead of tasks[1]....
Nov 16 '05 #1
0 776

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

Similar topics

3
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
4
by: Stephan & Saori | last post by:
I found a "weird" problem running windows 2003 Server. Maybe it's a know problem but I just wanted to make sure everyone knows. When running explorer to find the directories on my hard disk. It's...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
1
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder and Textbox onto the Web form, and try with the 4...
3
by: aling | last post by:
Execute following T-SQL within Queary Analyzer of SQL Server 2000: ======================================= DECLARE @dTest DATETIME SET @dTest='2001-1-1 1:1:1:991' SELECT @dTest SET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.