Click here to Skip to main content
15,896,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why do not save Login file in Server Explorer Pin
Pete O'Hanlon27-Apr-16 6:29
mvePete O'Hanlon27-Apr-16 6:29 
GeneralRe: Why do not save Login file in Server Explorer Pin
Sascha Lefèvre26-Apr-16 5:40
professionalSascha Lefèvre26-Apr-16 5:40 
GeneralRe: Why do not save Login file in Server Explorer Pin
OriginalGriff26-Apr-16 6:32
mveOriginalGriff26-Apr-16 6:32 
QuestionHelp with Listbox and comboBox Pin
Member 1231776424-Apr-16 23:40
Member 1231776424-Apr-16 23:40 
AnswerRe: Help with Listbox and comboBox Pin
koolprasad200324-Apr-16 23:55
professionalkoolprasad200324-Apr-16 23:55 
GeneralRe: Help with Listbox and comboBox Pin
Member 1231776424-Apr-16 23:56
Member 1231776424-Apr-16 23:56 
AnswerRe: Help with Listbox and comboBox Pin
BillWoodruff26-Apr-16 4:04
professionalBillWoodruff26-Apr-16 4:04 
GeneralRe: Help with Listbox and comboBox Pin
Sascha Lefèvre26-Apr-16 5:12
professionalSascha Lefèvre26-Apr-16 5:12 
QuestionHow to get/set SharePoint 2013 MySite properties through API? Pin
Coding Eyes24-Apr-16 23:32
Coding Eyes24-Apr-16 23:32 
AnswerRe: How to get/set SharePoint 2013 MySite properties through API? Pin
Eddy Vluggen25-Apr-16 3:12
professionalEddy Vluggen25-Apr-16 3:12 
QuestionHow to get selected item data of listView Column Item? Pin
0HourCoder23-Apr-16 9:36
0HourCoder23-Apr-16 9:36 
AnswerRe: How to get selected item data of listView Column Item? Pin
Sascha Lefèvre23-Apr-16 9:59
professionalSascha Lefèvre23-Apr-16 9:59 
GeneralRe: How to get selected item data of listView Column Item? Pin
0HourCoder23-Apr-16 10:25
0HourCoder23-Apr-16 10:25 
AnswerRe: How to get selected item data of listView Column Item? Pin
Simon_Whale23-Apr-16 22:24
Simon_Whale23-Apr-16 22:24 
QuestionI have this code that scans the memory of a program, the more programs that precision much memory takes a long time !! Any faster jeito to do this? Pin
Member 1248006323-Apr-16 5:46
Member 1248006323-Apr-16 5:46 
AnswerRe: I have this code that scans the memory of a program, the more programs that precision much memory takes a long time !! Any faster jeito to do this? Pin
OriginalGriff23-Apr-16 5:57
mveOriginalGriff23-Apr-16 5:57 
Questionhow do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:12
Member 1248006323-Apr-16 5:12 
QuestionRe: how do I get the information from a site of a button? Pin
CHill6023-Apr-16 5:15
mveCHill6023-Apr-16 5:15 
AnswerRe: how do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:28
Member 1248006323-Apr-16 5:28 
AnswerRe: how do I get the information from a site of a button? Pin
OriginalGriff23-Apr-16 5:30
mveOriginalGriff23-Apr-16 5:30 
GeneralRe: how do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:35
Member 1248006323-Apr-16 5:35 
GeneralRe: how do I get the information from a site of a button? Pin
CHill6023-Apr-16 5:38
mveCHill6023-Apr-16 5:38 
GeneralRe: how do I get the information from a site of a button? Pin
OriginalGriff23-Apr-16 5:44
mveOriginalGriff23-Apr-16 5:44 
GeneralRe: how do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:46
Member 1248006323-Apr-16 5:46 
Questionc# complex dictionary: can modify value in for-loop: thought you couldn't do that Pin
BillWoodruff23-Apr-16 0:10
professionalBillWoodruff23-Apr-16 0:10 
I don't know which is better, or worse, having code that works for reasons you don't understand, or having code that breaks for reasons you don't understand Smile | :)

Today I was testing the use of a complex dictionary of the form:
C#
public Dictionary<KeyValuePair<T1,T2>, List<T3>>
I was surprised to find that I could iterate ... in a lambda expression passed as the argument to a Func ... over the List of T3 with a 'for loop and change the values without getting the "attempt to modify ..." error. Example:
C#
Test = new Dictionary<KeyValuePair<string, int>, List<int>>
{
   {new KeyValuePair<string,int>("hello",1),
    new List<int> {1,2,3,4}},

   {new KeyValuePair<string,int>("goodbye",2),
    new List<int> {6,7,8,9}}
};

foreach (var kvp in Test)
{
    for (int i = 0; i < kvp.Value.Count; i++)
    {
        kvp.Value[i] *= 10;
    }
}
Of course, you can never change the value of the Key or Value of the KeyValuePair ... they have no setters, but, I was surprised I could modify the value in this kind of loop ... I assume I could always modify the value outside of a loop where I iterated across the structure.

So, why don't this break ? My memory includes the use of various yogic contortions a few years ago to avoid the "can't modify collection" error.

Come to think on it: I distrust code that works for reasons I don't understand more than ... the other Smile | :)

thanks, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.