|
Ok thanks for the info. Will save the settings in a seperate text file then.
Cheers
modified 1-Oct-21 21:01pm.
|
|
|
|
|
IMO, this is bad design. The app.config file is not meant for that purpose.
You may want to save the last record retrieved somewhere else. Maybe in the database itself, in another table. This would especially work well if you are using a stored procedure to retrieve the records.
Another solution would be to add a flag to the table where you retrieve the records to mark those who have been read.
|
|
|
|
|
It's not storing the value in the app.config file.
The settings object that you have added in visual studio automatically generates a bunch of code that uses the System.Configuration stuff.
Settings that you have chosen to be "Application" settings are stored in the app.config file, and cannot be modified in code. Settings that you choose to be "User" settings have their default value placed in the app.config file, but when you save a change to the value, the save is made to a config file stored in the current users local settings directory. ("C:\documents and settings\username\local settings\apps\appname\appversion\...." I think)
At runtime, when you request a value, the CLR first looks in the c:\docs & settings\... location to load a value from there. If there isn't anything there, it then goes to the app.config file, and finally, if there is nothing there, it uses a default value that is hard coded into the app.
This is why your app.config file always says 0. This is just the default value that is used when no user specific value exists.
Simon
|
|
|
|
|
Hi All
I'm new to C#, and i was wondering if something was possible. I have a switch statement where i want several criteria to lead to 1 bit of code, and another to lead to another etc.
Is there an easy way of doing this? or will I have to code write the same code out for each criteria?
Please help... Thanks...
oooo, the Jedi's will feel this one....
|
|
|
|
|
As long as you have nothing in between, you can fall through case statements in C# using:
switch (myItem)
{
case 1:
case 2:
case 4:
DoSomething();
break;
case 3:
case 5:
DoSomethingElse();
break;
default:
DoSomethingElseAltogether();
break;
} As soon as you put something between two of your case conditions, you have to fall back to the normal way of doing things.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
Your a star... Thanks...
oooo, the Jedi's will feel this one....
|
|
|
|
|
Hugo Monkey wrote: 1 bit of code, and another to lead to another etc
Put each 'bit' of code in a separate method and call the required method from the relavent case.
[Edit] Sorry, misunderstood the post slightly
Hugo Monkey wrote: several criteria
Use fallthrough as Pete suggested.
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)
|
|
|
|
|
The simplest way is to put your "bits of code" as functions
switch( blah )
{
case 0:
FunctionA();
break;
case 1:
FunctionA();
break;
case 2:
FunctionB();
break;
}
etc
|
|
|
|
|
Hi
Can some one tell what is the right algorithm to use Encrypt any files in C# and that need to be decrypted in Java by using key ? Show me some samples if you have..
Thanks
|
|
|
|
|
As long as you are using algorithms that both platforms understand, then there shouldn't be a problem. You could use SHA-1 for example.
Regards
Sebastian
|
|
|
|
|
you can try bouncycastle[^]
you can use any algorithms you like
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
Hi,
here is code line
Process.Start(@"C:\test.exe", @"C:\Temp Dir\sequence.seq");
the thing is the second string, because it has space in the directory name
the test.exe failes to open the file
i've changed the location to : C:\sequence.seq and it works fine
so it's not the file problem
how can i handle the sapce in the string??
thanks
Have Fun
Never forget it
|
|
|
|
|
Wrap it in quotes;
Process.Start(@"C:\test.exe", "\"C:\\Temp Dir\\sequence.seq\"");
Enjoy
I are troll
|
|
|
|
|
|
how can i get out from the outer for in a for-for-if situation.
For example
for...
{
for...
{
if...
{
break;
}
}
}
The break only breaks from the inner for, i want it to break from the outer for too.
Could you help.
|
|
|
|
|
you have to break it twice or use goto
for (int a = 0; a < 5; a++)
{
MessageBox.Show(a.ToString());
goto LoopBroke;
}
LoopBroke:
MessageBox.Show("Loop completed");
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Continue[^] also only breaks a single loop. You could add a flag called 'done', check this in the outer loop, and do a second break if it's true. Or, you use a goto[^].
Disclaimer: the goto suggestion should not be taken seriously
I are troll
|
|
|
|
|
You can't (See the reply from XMen)
You could consider restructuring the loop to use a while loop instead. You might find if you structure it differently that you don't need the break.
Simon
|
|
|
|
|
I suggest you go for the goto suggestion. While goto is discouraged, I find it helpful sometimes. It may even simplify the code more than what another structure would do. In this case, IMHO, it will (depending on the context too). A go to will not cost you an extra boolean value and saves an extra if statement.
Eslam Afifi
|
|
|
|
|
Your question shows that you have a misunderstanding of what a for loop actually does. I cringe whenever I see people use break statements inside for loops because it shows they've just gone for convenience without actually considering what they are trying to do.
A for loop is used to iterate a predictable and set number of times; that's what it's for (pardon the pun). If you need to iterate an indeterminate number of times, then you should consider using a boolean based loop structure, i.e. while ... do or do ... while instead (and yes - I know that a for loop is boolean based in that the exit condition is satisfied when you reach the to value in the count). Then, your logic makes more sense because you've based your exit on the condition you're testing.
Please, consider redoing your looping mechanism to a one that's a better fit. Whenever I see people recommending break or goto statements, I know that they are being lazy or have given no thought to what the proper use of the loop should be.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
|
I've looked really hard, but I can't find a '6' button anywhere, so unfortunately I'm only going to be able to vote you a 5. Sorry about that.
Fantastic.
Simon
|
|
|
|
|
Pete O'Hanlon wrote: I know that they are being lazy or have given no thought to what the proper use of the loop should be.
Well well well, first of all I'm not lazy... and by reading your answer, people will thing .Net Framework developer were fool because they made 'break'. Perhaps the programmers they use 'continue' are lazy too.
Now, take an example...you need to iterate an array until you got a value hmm... 9. Now how you gonna do
for (int a=0; a < arrayx.Length; a++)
{
if (arrayx[a] == 9)
break;
}
or
bool foundNine = false;
int index = 0;
while(!foundNine)
{
if (arrayx[index] == 9)
foundNine = true;
index++;
}
I'll always prefer the first one...I dunno about you, it may look you a work of lazy coder.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: Well well well, first of I'm not lazy
Perhaps not, but you aren't thinking about proper use of language constructs - hence my original comment.
int index = 0;
while (arrayx[index++] != 9)
{
} That's how you'd do your example - now, you can justify yourself as long as you like but you are promoting a bad practice. Now, let's extend your sample to see why it's bad practice.
bool foundNine = false;
for (int i = 0; i < array.length; i++)
{
if (array[i] == 9)
{
foundNine = true;
break;
}
}
if (foundNine && SomeOtherCondition())
{
DoSomething(array[i]);
} Contrast this with:
int index = 0;
bool foundNine = false;
do
{
if (array[index] == 9)
{
foundNine = true;
}
else
{
index++;
}
} while (!foundNine);
if (foundNine && SomeOtherCondition())
{
DoSomething(array[index]);
} I don't know about you, but this doesn't feel like such a horrible hack.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
aha nice done...but 'break' isnt worthless
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|