|
GuyThiebaut wrote: structures are new to me so I will give them a go.
Famous last words...
You should stick to using classes until you have read up on what structures are used for, and how to implement them.
GuyThiebaut wrote: From what I understand structs are kept on the stack
Only if you declare one as a local variable in a method. If you put one in an ArrayList, an object is allocated on the heap to put the structure in. This is called boxing, and isn't very good for performance.
Also, your data contains objects, and they will always be stored on the heap, so there is not really much point in putting it in structures.
GuyThiebaut wrote: so access is faster as well
The structures would be a bit big, so they would actually not be that fast to access. A structure should not be larger than 16 bytes, and your data would be pushing that recommended limit.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks - that's very helpful
In terms of size my data would definitely be pushing beyond the 16 byte limit.
Time to read up on structures.
You always pass failure on the way to success.
|
|
|
|
|
Puttings structs in an ArrayList? I'm just waiting for the next question from this guy:
"I have a struct in an ArrayList, but when I try to change the values in the struct, it doesn't work. The struct in the ArrayList just stays the same."
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If it does what you need...
|
|
|
|
|
PIEBALDconsult wrote: If it does what you need...
... you're done.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks - I'm always trying to learn how to write more, to make use of an overused word, beautiful code.
So easy maintainability, speed of access, resource hungriness(starting to sound like GW) and elegance of coding are important to me as I have written some awful code in my time and had to maintain the some pretty badly written code.
You always pass failure on the way to success.
|
|
|
|
|
Maybe you want to change your sig, and aim at success from the start, trusting you will NOT
always pass failure...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
As with Post-Its, some failures are successes in disguise.
I have (or had) a button that states:
"If at first you don't succeed, lower you standards."
|
|
|
|
|
PIEBALDconsult wrote: some failures are successes in disguise
Absolutely, keep an open mind and look for unexpected opportunities...
PIEBALDconsult wrote: If at first you don't succeed, lower you standards
Nope. If your aim is worthwhile then keep your standards high, and increase your perseverance,
I would say.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Unless you are stuck with framework 1.x, don't use the ArrayList class. It's obsolete.
Instead of storing different types of data in ArrayLists, make objects to store the data in, and make generic lists to store objects in.
List<C1> - contains N members
class C1 - contains:
3 strings
1 List<C2> - contains N members
class C2 - contains:
1 sting
1 byte
1 DateTime
This way you get rid of the boxing involved with storing value types in an ArrayList, the overhead of using ArrayLists only to store different kind of data, and you gain strict typing.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I've ended up using your list suggestion -it's a much better solution.
Thanks
You always pass failure on the way to success.
|
|
|
|
|
Hello,
I have a program that I'm writing that sets up a little question and answer form by reading its items through a several XML documents and displaying each one on a seperate form. I am having a problem with one user who cannot see any of the controls that are created by the XML form. IE... it will load a blank form with no user controls on it. On his other computer (both Windows XP), it works fine. Anyone know any potential culprits?
Thanks,
Phil
|
|
|
|
|
PhilDanger wrote: I am having a problem with one user
Are you sure it's not a PEBKAC?
But seriously, if this problem is isolated to one PC, which is how I understand your description of the problem, I'd be suspicious that it's the PC's problem. What exactly I can only guess. Maybe the .NET Framework needs an update? Maybe...?
BDF
A learned fool is more a fool than an ignorant fool.
-- Moliere
|
|
|
|
|
Could the issue relate to screen resolution ? I doubt it, but beyond that, his PC is hosed.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Help on navigating within rows and columns within a worksheet using C#.
|
|
|
|
|
In Excel, you mean? What exactly do you need help with? Have you looked up Visual Studio Tools for Office?
|
|
|
|
|
Check out this[^] article. It's based on J# but if you're smart enough you will figure it out how to do same things in Excel using C#.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
|
HI ,
Pubs is my sample data base
I have a problem retrieving the correct value
My SQL Query in the xsd table adapter by the name "ByState" is as follows
select Sum( all sales.qty) as TotSaleQty from sales left join stores on sales.stor_id = stores.stor_id where stores.state = @state
C# Code under button click
protected void btn_State_Click(object sender, EventArgs e)
{
ByStateTableAdapter qtyStateTA = new ByStateTableAdapter();
string stateName = ddl_State.SelectedValue.ToString().Trim();
string qtyState = qtyStateTA.Get_Qty_ByState(stateName).ToString();
txt_State.Text = qtyState;
}
While Debugging The values that is being stored in qtyState is "ByState" and not the actual result which is a number.
Please let me know how to handle it.
Regards.
ctrlnick
Happy Programming!
Regards,
ctrlnick !
|
|
|
|
|
I have created the setup file in my c# application.One empty folder and one aspx file folder is their in this application.I have installed in this setup file My system to another System .After installation in another system only aspx file folder is displayed do not display the Empty folder.
How to display the both empty folder and aspx file folder in after deployed.
|
|
|
|
|
|
your problem is not clear , can you please explain in details ?
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
Hello everyone,
I've been searching around how to interact with an open instance of Messenger. Has anybody got a link to a resource or an article as to how retrieve and sende messages via Messenger?
I'm thinking of a Managed library - thougt I'm not sure dotMSN is what I'm looking for.
My aim is to programmatically catch incoming messages, send messages and retrieve the online user list.
I could as well implement an MSN add-in, but I'm not really sure how to go about with that.
Thanks in advance.
Edit: I just noticed a similar thread in this page of the forum. I apologise for the repetition.
|
|
|
|
|
Try Google[^]. There are some pages that might be helpful.
|
|
|
|
|
I'm trying to write an ASP.NET application with thread safety in mind (not one of my strength points). I use the static class shown below for the application settings (not the real code, just a simplified version):
public static class AppSettings
{
private static int _setting1;
public static int Setting1
{
get { return _setting1; }
}
private static string _setting2;
public static string Setting2
{
get { return _setting2; }
}
static AppSettings()
{
LoadSettings();
}
public static LoadSettings()
{
}
public static ReloadSettings()
{
LoadSettings();
}
}
As you can see in the code above, LoadSettings() is called from two locations, the first is from the static constructor (no problem here, the static constructor is thread safe) and from ReloadSettings() (where the problem is) what I'm trying to do is that I want to block all threads from accessing the settings in the private members (accessed through the properties) until all the settings are updated, is this possible using a static class?
I figured out that I could change the code to be as below and the problem will be solved:
public static class AppSettings
{
private static AppSettingsData _appSettingsData;
public static int Setting1
{
get { return _appSettingsData.Setting1; }
}
public static string Setting2
{
get { return _appSettingsData.Setting2; }
}
static AppSettings()
{
LoadSettings();
}
public static LoadSettings()
{
int setting1;
string setting2;
AppSettingsData settingsData = new AppSettingsData(setting1, setting2);
_appSettingsData = settingsData;
}
public static ReloadSettings()
{
LoadSettings();
}
}
public class AppSettingsData
{
public AppSettingsData(int setting1, string setting2)
{
_setting1 = setting1;
_setting2 = setting2;
}
private int _setting1;
public int Setting1
{
get { return _setting1; }
}
private string _setting2;
private string Setting2
{
get { return _setting2; }
}
}
Although this would solve the problem, I actually still prefer to use a static class for everything (unless of course it's not possible using a static class), and also out of curiosity I would like to know whether this is possible or not with only a static class.
Your help is very much appreciated...
modified on Friday, April 11, 2008 9:31 AM
|
|
|
|