Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: want to change theme of controls..... Pin
Dave Kreskowiak4-Jun-10 1:45
mveDave Kreskowiak4-Jun-10 1:45 
GeneralRe: want to change theme of controls..... Pin
Johnny J.4-Jun-10 2:25
professionalJohnny J.4-Jun-10 2:25 
GeneralRe: want to change theme of controls..... Pin
Dave Kreskowiak4-Jun-10 4:36
mveDave Kreskowiak4-Jun-10 4:36 
QuestionHow to Create DB in SQL server Pin
Joe Rozario3-Jun-10 18:05
Joe Rozario3-Jun-10 18:05 
AnswerRe: How to Create DB in SQL server Pin
dan!sh 3-Jun-10 18:26
professional dan!sh 3-Jun-10 18:26 
GeneralRe: How to Create DB in SQL server Pin
Joe Rozario4-Jun-10 0:14
Joe Rozario4-Jun-10 0:14 
AnswerRe: How to Create DB in SQL server Pin
Gonzalo Cao4-Jun-10 3:29
Gonzalo Cao4-Jun-10 3:29 
QuestionDisparity between value semantics behavior with List< struct > vs. array of struct Pin
Stache3-Jun-10 15:07
Stache3-Jun-10 15:07 
I may be having dense programmer moment, but I just spent an hour debugging something that came down to a really unexpected (by me, at least) behavior with List<> vs. array. If you create a struct with a method that modifies a member, and invoke that method on an instance of the struct that resides within an array, the array element is modified as you would expect. But if you perform the identical operation on the struct that is contained in a List<structs>, the item in the List is NOT modified. The following program illustrates this...the effect is observable in VS 9 and 10.

Does this seem correct or reasonable? It certainly doesn't adhere to one of my favorite principles of language design: the principle of least surprise!

thanks, jim

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace TestByValue
{
    class Program
    {
        static void Main(string[] args)
        {
            Foo[] aArray = new Foo[3];
            aArray[0].Increment();

            Console.WriteLine("aArray[0].x is {0} and should be {1}", aArray[0].x, 1);
            Debug.Assert(aArray[0].x == 1);

            List<Foo> aList = new List<Foo>();
            aList.Add(new Foo());
            aList[0].Increment();

            Console.WriteLine("aList[0].x is {0} and should be {1}", aList[0].x, 1);
            Debug.Assert(aList[0].x == 1);      // This Assert fires
        }

        struct Foo
        {
            public int x;

            public void Increment()
            {
                x++;
            }
        }
    }
}

AnswerRe: Disparity between value semantics behavior with List vs. array of struct [modified] PinPopular
Anthony Mushrow3-Jun-10 17:19
professionalAnthony Mushrow3-Jun-10 17:19 
GeneralRe: Disparity between value semantics behavior with List vs. array of struct Pin
Stache4-Jun-10 4:23
Stache4-Jun-10 4:23 
QuestionEnglish wordlist database for word processing app?? Pin
Jaison V3-Jun-10 7:57
Jaison V3-Jun-10 7:57 
AnswerRe: English wordlist database for word processing app?? Pin
#realJSOP3-Jun-10 8:14
mve#realJSOP3-Jun-10 8:14 
GeneralRe: English wordlist database for word processing app?? [modified] Pin
Jaison V3-Jun-10 21:16
Jaison V3-Jun-10 21:16 
GeneralRe: English wordlist database for word processing app?? Pin
PIEBALDconsult4-Jun-10 5:30
mvePIEBALDconsult4-Jun-10 5:30 
JokeRe: English wordlist database for word processing app?? Pin
Jaison V4-Jun-10 9:33
Jaison V4-Jun-10 9:33 
GeneralRe: English wordlist database for word processing app?? Pin
#realJSOP5-Jun-10 4:20
mve#realJSOP5-Jun-10 4:20 
GeneralRe: English wordlist database for word processing app?? Pin
Jaison V4-Jun-10 9:35
Jaison V4-Jun-10 9:35 
GeneralRe: English wordlist database for word processing app?? Pin
#realJSOP5-Jun-10 4:18
mve#realJSOP5-Jun-10 4:18 
QuestionHow to replace windows login form... Pin
Xelalem3-Jun-10 7:08
Xelalem3-Jun-10 7:08 
AnswerRe: How to replace windows login form... Pin
Hristo-Bojilov3-Jun-10 10:22
Hristo-Bojilov3-Jun-10 10:22 
AnswerRe: How to replace windows login form... Pin
Dave Kreskowiak3-Jun-10 11:06
mveDave Kreskowiak3-Jun-10 11:06 
GeneralRe: How to replace windows login form... Pin
V.3-Jun-10 23:45
professionalV.3-Jun-10 23:45 
GeneralRe: How to replace windows login form... Pin
Henry Minute4-Jun-10 0:37
Henry Minute4-Jun-10 0:37 
GeneralRe: How to replace windows login form... Pin
V.4-Jun-10 1:41
professionalV.4-Jun-10 1:41 
GeneralRe: How to replace windows login form... Pin
Dave Kreskowiak4-Jun-10 1:44
mveDave Kreskowiak4-Jun-10 1:44 

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.