Click here to Skip to main content
15,914,014 members
Home / Discussions / C#
   

C#

 
QuestionAn array of bitmaps Pin
sebogawa22-Mar-10 13:40
sebogawa22-Mar-10 13:40 
AnswerRe: An array of bitmaps Pin
DaveyM6922-Mar-10 13:42
professionalDaveyM6922-Mar-10 13:42 
AnswerRe: An array of bitmaps Pin
Luc Pattyn22-Mar-10 14:25
sitebuilderLuc Pattyn22-Mar-10 14:25 
GeneralRe: An array of bitmaps Pin
Not Active22-Mar-10 14:29
mentorNot Active22-Mar-10 14:29 
GeneralRe: An array of bitmaps Pin
Luc Pattyn22-Mar-10 14:40
sitebuilderLuc Pattyn22-Mar-10 14:40 
Questionlock the application for the process [modified] Pin
Jassim Rahma22-Mar-10 12:04
Jassim Rahma22-Mar-10 12:04 
AnswerRe: lack the application for the process Pin
Not Active22-Mar-10 12:29
mentorNot Active22-Mar-10 12:29 
GeneralRe: lack the application for the process Pin
Jassim Rahma23-Mar-10 4:00
Jassim Rahma23-Mar-10 4:00 
GeneralRe: lack the application for the process Pin
Not Active23-Mar-10 4:17
mentorNot Active23-Mar-10 4:17 
Questioncall private void btnSave_Click(object sender, EventArgs e) Pin
Jassim Rahma22-Mar-10 11:58
Jassim Rahma22-Mar-10 11:58 
AnswerRe: call private void btnSave_Click(object sender, EventArgs e) Pin
Kristian Sixhøj22-Mar-10 12:02
Kristian Sixhøj22-Mar-10 12:02 
AnswerRe: call private void btnSave_Click(object sender, EventArgs e) Pin
ricmil4222-Mar-10 12:04
ricmil4222-Mar-10 12:04 
AnswerRe: call private void btnSave_Click(object sender, EventArgs e) Pin
Luc Pattyn22-Mar-10 14:47
sitebuilderLuc Pattyn22-Mar-10 14:47 
GeneralRe: call private void btnSave_Click(object sender, EventArgs e) Pin
ricmil4223-Mar-10 3:26
ricmil4223-Mar-10 3:26 
AnswerRe: call private void btnSave_Click(object sender, EventArgs e) [modified] Pin
DaveyM6922-Mar-10 12:35
professionalDaveyM6922-Mar-10 12:35 
AnswerRe: call private void btnSave_Click(object sender, EventArgs e) Pin
AspDotNetDev22-Mar-10 13:37
protectorAspDotNetDev22-Mar-10 13:37 
GeneralRe: call private void btnSave_Click(object sender, EventArgs e) Pin
Not Active22-Mar-10 14:09
mentorNot Active22-Mar-10 14:09 
QuestionForm is Flickering Pin
Jassim Rahma22-Mar-10 11:53
Jassim Rahma22-Mar-10 11:53 
AnswerRe: Form is Flickering Pin
Kristian Sixhøj22-Mar-10 12:00
Kristian Sixhøj22-Mar-10 12:00 
QuestionThe WebBrowser control Pin
BuggingMe22-Mar-10 10:24
BuggingMe22-Mar-10 10:24 
Questionrecording sound from speakers Pin
rosin722-Mar-10 9:14
rosin722-Mar-10 9:14 
AnswerRe: recording sound from speakers Pin
DaveyM6922-Mar-10 10:33
professionalDaveyM6922-Mar-10 10:33 
QuestionModify Collection using LINQ Pin
uusheikh22-Mar-10 9:05
uusheikh22-Mar-10 9:05 
I have a simple question, but i don't know how to do it.
I have a collection of data, and would like to query it using LINQ. Then, i want to modify the resultant collection, which updates the original collection

For example
i have the following collection
int[] data = { 0, 1, 2, 3, 4, 5 };

I want to select all data larger than 3 (thus 4 and 5), and then modify them by multiplying them with 10.
My final collection should look like this. (This is a simple example, in reality, i will be using a complex object)

data = {0, 1, 2, 3, 40 , 50};

I tried this; but doesn't update the original collection. Does ToList() return a copy of the collection?
How do i go about doing this?

int[] data = { 0, 1, 2, 3, 4, 5 };

            var a = from n in data
                    where n > 3
                    select n;



            List<int> b = a.ToList();
            for (int i = 0; i < b.Count(); i++)
            {
                b[i] = 10*b[i];
                Console.WriteLine(b[i]);
            }

            for (int i = 0; i < data.Count(); i++)
                Console.WriteLine(data[i]);


Data still contains 0,1,2,3,4,5 instead of 0,1,2,3,40,50,which is what i want.
Please help, many thanks.
AnswerRe: Modify Collection using LINQ Pin
Gideon Engelberth22-Mar-10 9:30
Gideon Engelberth22-Mar-10 9:30 
AnswerRe: Modify Collection using LINQ Pin
Dave Kreskowiak22-Mar-10 10:50
mveDave Kreskowiak22-Mar-10 10:50 

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.