|
Hi,
the long/int64 type in C# can hold 18-digit numbers
since 10^18 = 1000^6 =almost= 1024^6 = 2^60; or 63*0.301 = 18.9 where 0.301=log10(2)
if your code does not perform as expected, something is wrong.
You may want to publish both the relevant parts of the code, and the exact symptoms.
|
|
|
|
|
Hi Luc. I think I may have found the problem. I shold have gone back to the route of where it could have stemmed from which is at the import stage. I was importing them as Int32's. I changed that now and it seems to be working. I just need to check this to see if I get the same total as what the app is getting now.
How do I get this to run faster. It seems to take a good 2 minutes to import and calculate 3500 records. Below the full code listing.
FileHelperEngine<imphash> engine = new FileHelperEngine<imphash>();
engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
imphash[] res = engine.ReadFile(filepath);
if (engine.ErrorManager.ErrorCount > 0)
engine.ErrorManager.SaveErrors("Errors.txt");
foreach (imphash hsh in res)
{
txtboxdisplay.Text += hsh.Field1 + Environment.NewLine;
}
long sum = 0;
foreach (imphash hsm in res)
{
sum += Convert.ToInt64(hsm.Field1.ToString());
}
txtboxdsptxt.Text = (sum.ToString() + Environment.NewLine);
}
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
I found that writing the data to a text box was what was the delay and not the calculation.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
And now you are using a string variable and append to it with += ?
Then you'll find that it's still very slow when you get to large strings (because the whole string needs to be copied for each concatenation).
You should use a StringBuilder instead.
|
|
|
|
|
Hi Kwagga,
your code is doing several things: getting data, outputting it to a textbox,
summing it. If this takes too long, first thing you should do is find out which
part is responsible, typically by either inserting accurate timing code, or
by disabling some of the parts.
My best guess is the display part is the culprit.
For one thing, you are creating N different strings (N=3500), where each new
string is built with +=, hence needs to copy all the previous content.
And you are telling the txtboxdisplay to update itself N times.
If line wrapping is irrelevant (I guess it is), I strongly recommend you replace
the textbox by a ListBox; a ListBox is very good at displaying a large number of
independent lines of text, it never needs them to be concatenated, and it updates
very fast since it only processes a change, as in ListBox.Items.Add(string) .
|
|
|
|
|
Yeah, I found that it was the displaying of the items. I have cut that bit out of the code cause I don't really require it. It now takes a split second to process 100 000 records.
Thanks again.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
decimal theNum = 12345678901234567890;
ulong theNum2 = 12345678901234567890;
MessageBox.Show(theNum.ToString() + " - " + theNum2.ToString());
-= Reelix =-
|
|
|
|
|
You could use the decimal type.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks mate. I have figured out what the problems was. I was importing the data as Int32 and after changing that to long it worked fine.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
hello frnds,
can i pass optional parameter to C#.NET method like VB.NET ???
if yes then how ???
is there any another option to get it ?
thankx in advance
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
No, you cannot. You have to create a chain of methods with less parameters that call the longer methods with the default
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 )
|
|
|
|
|
koolprasad2003 wrote: can i pass optional parameter to C#.NET method like VB.NET
No, you can't.
koolprasad2003 wrote: is there any another option to get it ?
You can make overloaded methods. You can use nullable values.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
May be you can try like htis
public void TestFunc(int requiredParam1,int requiredParam2,parms object[] optionalParms)
{
if(optionalParms.Length > 0)
{
//Do what ever you want.
}
}
Now you can call them like
TestFunc(1,2);
TestFunction(1,2,"Hello");
TestFunction(1,2,"Hello","World");
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
C# doesn't support optional parameters and this can be handled by overloading functions. For an instance consider you want a same method should handle 2 and 4 parameters
private void BindComboBoxWithDataSource(RadComboBox RADComboCtrl,object DataSourceObject)
{
RADComboCtrl.DataSource = DataSourceObject;
RADComboCtrl.DataBind();
RADComboCtrl.Items.Insert(0,new RadComboBoxItem(NOOPTIONSELECTED_TEXT));
}
private void BindComboBoxWithDataSource(RadComboBox RADComboCtrl, object DataSourceObject, string DataTextField, string DataValueField)
{
RADComboCtrl.DataSource = DataSourceObject;
RADComboCtrl.DataBind();
RADComboCtrl.DataTextField = DataTextField;
RADComboCtrl.DataValueField = DataValueField;
RADComboCtrl.Items.Insert(0, new RadComboBoxItem(NOOPTIONSELECTED_TEXT));
}
Udai.m
Solution Architect
|
|
|
|
|
Hi,
I need to create an executable in c# which unchecks the "Automatically Detect Settings" checkbox in Internet Explorer Options, LAN Settngs.
Any Help?
Thanks
|
|
|
|
|
What makes you think that IE exposes that ? If it does, probably it's in the registry.
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 )
|
|
|
|
|
Yeah, It is in Registry only. I mean how to do that by some exe and which key is that.
|
|
|
|
|
This option is a combination of two Keys in this registry path
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
There are two settings which are changing if you select / deselect the Option "Automatically Detect Settings".
DefaultConnectionSettings
SavedLegacySettings
Hope this helps
Tiefe Brunnen muss man graben wenn man klares Wasser will,
tiefe Wasser sind nicht still.
|
|
|
|
|
Hi Friends,
How to retreive values from .CSV file in C#.Please help me how to do.
Thanks & Regards
Senthil Kumar.T.S
|
|
|
|
|
File.ReadAllText and then the split method to split the string on the , so you get an array of values to parse.
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 )
|
|
|
|
|
Hi Christian Graus,
Can you give me a example? Please?
|
|
|
|
|
In addition to what CG said, there are quite a few libraries that do this. If you want to do it yourself, make sure you handle cases like the items being enclosed in double quotes. I always do that so I can have spaces and other special characters (including the comma itself) in my items.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
Hi Friends,
Can you tell me how to connect .CSV file with C# and retreive the values.As CG said by File.ReadAllText we can split the string and get the method.Can give me a example code so that i can get an idea, because i searched in google but i can't get the solution.
Thanks & Regards
Senthil Kumar.T.S
|
|
|
|
|
|