|
Hi,
If you cast the enumerator's Current value to a SettingsProperty then you should get to the information you need. My code essentially does that and shows how to enumerate both the default and current value collections.
internal void ShowSettings() {
Console.WriteLine("Default values");
SettingsPropertyCollection spc = Properties.Settings.Default.Properties;
foreach (SettingsProperty sp in spc) {
Console.WriteLine("{0} '{1}'", sp.Name, sp.DefaultValue);
}
Console.WriteLine("\nCurrent values");
SettingsPropertyValueCollection spvc = Properties.Settings.Default.PropertyValues;
foreach (SettingsPropertyValue spv in spvc) {
Console.WriteLine("{0} '{1}'", spv.Name, spv.PropertyValue);
}
}
Alan.
|
|
|
|
|
Thanks both for your prompt responses. Case closed.
|
|
|
|
|
I have read many articles on expception handling in C# and I have a question regarding the use of multiple catch blocks. Is there any purpose for using multiple (specific) catch blocks if all exceptions will be handled the same way?
NOTE: At the moment I am only adding exception logging to the application not exception handling.
|
|
|
|
|
Hi,
if you want to catch *all* Exception types and threat them identically, then no there is no use in having separate catch blocks.
BTW: logging is fine, not dealing with the Exception probably is a poor choice, since (unless you rethrow the Exception) the caller will be unaware something went wrong.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks Luc. I am planning on doing something with the exception besides swallowing it...Probably rethrow, I just haven't decided yet.
|
|
|
|
|
proganon wrote: Is there any purpose for using multiple (specific) catch blocks if all exceptions will be handled the same way?
A resounding No.
The only place where this would be valid is if you wanted to catch and handle CustomException1 and CustomException2 in the same way and leave the rest for calling code to handle, where said Exception types are unrelated to each other.
Cheers,
Vikram. Current activities:
Films: Philadelphia
TV series: Friends, season 4
Books: Six Thinking Hats, by Edward de Bono. Carpe Diem.
|
|
|
|
|
proganon wrote: Is there any purpose for using multiple (specific) catch blocks if all exceptions will be handled the same way?
Yes. This provides the ability to handle specific exceptions in a sensible fashion - for instance, you might have a bit of code that updates a database, and the SQL Connection terminates unexpectedly during the operation - you might want to attempt the update again (having reopened the connection). If you get a different type of exception, you probably wouldn't want to attempt the update again.
There's just one example of doing this.
"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 | Onyx
|
|
|
|
|
Hi
My C# project throws a System.NullException outside VS so I can't find where the problem is. How can I debug while my application runs outside VS?
Thanks in advance.
|
|
|
|
|
Two obvious possibilities:
1) run it inside VS and see where the error is.
2) put in a try - catch block and print out the exception content.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
The weird thing is that it doesn't give an error while working inside VS.
I will try try-catch block with printing out exception content.
|
|
|
|
|
Thanks to your help I found where the error is. But I can't understand why it throws an error.
Here is the code:
string gorev = null;
string pcadi = "*****";
WebClient wc = null;
Stream s = null;
StreamReader sr = null;
try
{
wc = new WebClient();
s = wc.OpenRead(main + get + "?updatecheck=" + pcadi);
sr = new StreamReader(s);
gorev = sr.ReadLine();
}
catch { gorev = null; }
finally { sr.Close(); sr.Dispose(); s.Close(); s.Dispose(); wc.Dispose(); }
|
|
|
|
|
When you use catch(Exception exc) { Console.WriteLine(exc.ToString());} or something similar you will get all available details about the exception often including the line number. And it is wise to tell Visual Studio (or any other IDE) to always display line numbers in editor windows, so now you know exactly which line goes wrong.
BTW: The fact that a program sometimes works just fine does *not* prove it is correct.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I think that some versions of VS allow you to attach the debugger to a managed application. Not sure how you would go about this though - I use the Express edition
|
|
|
|
|
Hi Experts,
am working with c#.net 3.5, Windows Application
How can i add a default image to every row of my datagridview?
please help me out.
Thanks In Advance.
|
|
|
|
|
The easiest way to do this is to use an unbound DataGridViewImageColumn.
Something like this:
DataGridViewImageColumn imageCol = new DataGridViewImageColumn();
imageCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
imageCol.ImageLayout = DataGridViewImageCellLayout.Normal;
imageCol.Frozen = true;
imageCol.Name = "Image";
imageCol.HeaderText = "";
imageCol.DisplayIndex = 0;
imageCol.Image = genericImage;
dataGridView1.Columns.Add(imageCol);
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Guys
i have an array below
string stringArray = new strinArray[12];
stringArray[0] = "0,1";
stringArray[1] = "1,3";
stringArray[2] = "1,4";
stringArray[3] = "2,1";
stringArray[4] = "2,4";
stringArray[5] = "3,7";
stringArray[6] = "4,3";
stringArray[7] = "4,2";
stringArray[8] = "4,8";
stringArray[9] = "5,5";
stringArray[10] = "5,6";
stringArray[11] = "6,2";
i need to transform like below
List<List<string>> listStringArray = new List<List<string>>();
listStringArray[["1","3","4"],["1","4"],["7"],["3","2","8"],["5","6"],["2"]];
how is that possible?
modified on Tuesday, May 26, 2009 11:27 AM
|
|
|
|
|
"someString".Split and logic.
|
|
|
|
|
i know to split man.i actually need to logic
|
|
|
|
|
The logic isn't the hard part here.. actually there is no hard part at all.
|
|
|
|
|
Try looking at the documentation for the generic list constructor. If you can't figure it out from there you may have a PEBKAC error.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: you may have a PEBKAC error
Not heard that one before - thank you (and google for the explanation)!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
wow, is your code compiling? It's very strange.
To convert an array to list, try this wonderful website : herehere
|
|
|
|
|
if easy so you write for me here man
|
|
|
|
|
no one is going to write you code here, you can go to this site[^] if that's what you're looking for.
|
|
|
|
|
do you need money man?
you know something please share me but shut up.
|
|
|
|