|
In summary, you can use (in decreasing 'quality' order):
1 returning one reference value (say an instance of class myResults) holding all the results
this is the preferred way, certainly if lots of results need to be made available
2 returning a small struct
small here means no more than 8 bytes (e.g.2 ints)
3 one ref or out parameter holding a struct
this avoids the creation of the myResults instance
4 returning a large struct
this causes a lot of data moving around when there are many results to report
5 out or ref parameters each holding a simple variable
this gets clumsy and cumbersome very soon
6 public class members in the class that contains your method, so you can obtain
whatever subresult you may need
not structured, not thread-safe, the complete opposite of modern OO techniques
So I suggest you try and stick to 1, 2 and 3.
Luc Pattyn
|
|
|
|
|
I always like reading your summary!
First of all because it's always well structured and of corse correct!
But also because you are not using specialized english words which are difficult to understand (for me at least)!
Thanks!
|
|
|
|
|
My code is,
AxMSChart20Lib.AxMSChart chart = new AxMSChart20Lib.AxMSChart();
chart.Title.Text = "My first chart";
this.Controls.Add(chart);
When i use this code, i get this exception,
"InvalidActiveXSateException was unhandled"
Exception of type:
'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.
Can u tell, how can this be corrected?
Thanks for your time and patience-Guna
|
|
|
|
|
Hi can anyone help me create a simple calculator using asp.net web form with C# language. Or if anyone could help me locate one
thankyou.
|
|
|
|
|
Smells like homework. What have you done already ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
thanks for the help, reallly appreciate it.
|
|
|
|
|
I am looking for an interactive diagram component for WinForms. If you have seen or used Corgent Diagrams then thats what I need. Corgent Diagrams is really neat but really expensive too.
What I need is the ability to create diagrams in design time then load the diagram into a Winforms application and then let the user double click or right click different parts/shapes/connectors in the diagram to select various menu options. So imagine a flowchart created in design time. When a user right clicks on a certain shape I want to be able to handle the event and present the user with a menu based on the shape. Imagine loading a visio file into your application and then wiring all events on all shapes to some code. Does anyone know of such a library or component?
Thanks.
|
|
|
|
|
Ok, I'm having a few problems with designer in Visual Studio...
I have a MainToolbar class which has buttons on it (e.g. Forward, Back). The buttons are private but they're exposed publicly via various Properties, e.g. ForwardShown, ForwardEnabled. These properties have 3 Attributes...
[Browsable(true), Category("Icons Visible"), DefaultValue(true)]
Now I place the MainToolbar on a Form called FormBaseEdit and it works well.
The value for the properties like ForwardShown is true and NOT bold (as it should be). The MainToolbar is a protected member of FormBaseEdit.
The problem comes when I then inherit from FormBaseEdit.
The properties of the MainToolbar is still true However they are now BOLD. IF you change them to false they are not bold. Then when you build the project the properties that you changed to false are automatically back to true.
Does anyone know how to stop this?
Thanks,
Chris McGrath
|
|
|
|
|
Hello Chris,
it seems that you forgot to initialize the local variables of your properties.
Setting the DefaultValue Attribute to "true" is not sufficient.
If it was DefaultValue(false), you would have luck because the boolean default is "false".
That means you would have to do:
private bool testProp = true;
[Browsable(true), Category("Icons Visible"), DefaultValue(true)]
public bool TestProp
{
get
{
return testProp;
}
set
{
testProp=value;
}
}
All the best,
Martin
|
|
|
|
|
My MainToolbar contains a ToolStrip which has the buttons on it, the buttons already default to true, so my properties look like
<br />
[Browsable(true), Category("Icons Visible"), DefaultValue(true)]<br />
public virtual bool FirstShown<br />
{<br />
get { return btnFirst.Visible; }<br />
set { btnFirst.Visible = value; }<br />
}<br />
As I said it works perfectly if I place it on a form.
The problem is when I inherit from the form which it is on, the Default Value Actually changes from false to true. So if I change FirstShown to false, it looses its boldness, doesn't write the line in the designer file, and when it builds it puts the value back to true.
Thanks,
Chris
|
|
|
|
|
Hello Chris,
Hmmm?
I tested it now with a simple user control which has a button on it.
I placed it on a baseform and inherit a formclass from that baseform.
And.. Same effect than you have!!
I have no real explination for that, but it hs something todo with the timing of the designer.
The designer runns the constructor code of your controls, maybe at the time where he whants to get youre property, the button is not initialized. (Just out of my head.)
I would suggest you aworkaround like this:
private bool testProp = true;
[Browsable(true), Category("Icons Visible"), DefaultValue(true)]
public bool TestProp
{
get
{
return testProp;
}
set
{
testProp = value;
button1.Visible=value;
}
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hello everyone:
I'm trying to add the my (Setup1) application to this installer package. When I right-click on Application Folder on the File System Editor. From the contextual menu, select Add, Project Output. The Project Output Group dialog box is Empty. There is no Primary output, Content Files or Source Files and the Project: drop-down is blank.
Pleae help. Thanks
|
|
|
|
|
Hi guys, i am reading text from a text file and searching a pattern and replacing through regular expression. I am wondering how can i write to spceified line meanwhile i am reading from a textfile. basically if there is a match found in the entire file i want to replace the string and store in the file permenantly. Is a best way to do.
Your help would be appreciated.
Thanks
|
|
|
|
|
File.ReadAllText + Regex.Replace + File.WriteAllText ?
Luc Pattyn
|
|
|
|
|
Files are not line based, so you can't replace a line in a file.
In the odd case that the text you are replacing has the exact byte length when encoded as the text you are replacing it with, it would be possible to replace those bytes in the file. Otherwise you just have to read the whole file in, do the replacement, and write it all back to the file.
---
Year happy = new Year(2007);
|
|
|
|
|
Dear brothers
I need to have a listview like Madhu Raykar's but i can add more items to it by clicking a mouse, i mean how i catch the mouse event click for empty items ??
I hope I'm clear and plz provide me with answer ASAP
|
|
|
|
|
you mean like through a context menu???
...btw, the following is my signature. Not a code snippet
-- modified at 18:20 Monday 29th January, 2007
(Nyquist Rate || ! Nyquist Rate)
{
Console.WriteLine("That is the question");
}//Go Colts
|
|
|
|
|
I have a file that has informatin separated by (;) as follow
colors;serverName1;size;location
colors;serverName1;size;location
colors;serverName1;size;location
I want to read the servername (after the fist and last ";" )
any ideas how to do this?
thank you in advanced
PS
|
|
|
|
|
You can determine the index of the semicolons using the String.IndexOf method and then retrieve the server name by using the String.Substring method.
Alternatively, you can split the string using the String.Split method and the semicolon as delimiter and access the proper item of the returned array.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
String.Split is your friend.
Luc Pattyn
|
|
|
|
|
for the following:
float x = (38.40f * 1000.0f) - 32435.0f;
I get x = 5965.00146.
Surely floats are more accurate than this, or is there a problem I'm not seeing?
John Acton
|
|
|
|
|
No this is normal behavior for floats; their size is 32-bit, of which they use about 24 bits
for their mantissa, which amounts to about 7 decimal digits.
If you want more precision, use double; their size is 64-bit, the mantissa uses about 56 bits,
they can hold about 16 decimal digits.
If memory efficiency is important, you may want to store floats, but do intermediate calculations
with doubles.
If your application is financial (or anything else with a limited maximum value, that
requires accurate fractional digits) consider the decimal type.
BTW similar considerations exist in whatever programming language you choose...
Luc Pattyn
|
|
|
|
|
Thanks for your help.
John Acton
|
|
|
|
|