PC Review


Reply
Thread Tools Rate Thread

Alter the original items in the original array

 
 
Curious
Guest
Posts: n/a
 
      10th Aug 2010
I want to identity a subset of a collection, tradeProperyRows (defined
as DataRow[]). Then I want to switch the data (in two columns of
DataRow) in the subset (trsTrades).

However, I want to make sure that trsTrades is a collection of
pointers to the original array(tradeProperyRows), instead of a copy of
the items of the subset, because I want to alter the items in the
**original** array, tradeProperyRows.

Please let me know if the code below would do the job. Thanks!

// Use LINQ to get the subset that meets the criteria
IEnumerable<DataRow> selected = from n in tradeProperyRows
where
Regex.IsMatch(n["TRADETYPE"].ToString(), ".*TRS$")
select n;

// Get the subset to a List
List<DataRow> trsTrades = selected.ToList();

// Switch data in QUANTITY and PRINCIPAL columns in the subset
// Switch the data in the **original** array, tradeProperyRows!!!
foreach (DataRow dr in trsTrades)
{
if (dr.Table.Columns.Contains("PAY_TR_LEG"))
{
// Switch data in QUANTITY and PRINCIPAL columns

double tempFigure =
Convert.ToDouble(ClrDbTypeConverter.GetClrValue(dr["QUANTITY"]));

dr["QUANTITY"] =
Convert.ToDouble(ClrDbTypeConverter.GetClrValue(dr["PRINCIPAL"]));

dr["PRINCIPAL"] = tempFigure;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
register original sp1 instalation with original sp2 cdkey pedro_mpa Windows XP Setup 3 17th Oct 2008 08:37 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
quoting original text doesn't work if original mail is UTF-8 =?Utf-8?B?ZGlzY29ocg==?= Windows Vista Mail 8 21st Sep 2007 01:08 AM
I can't install a not original program in original windows xp =?Utf-8?B?RmVycmF6?= Windows XP Help 0 22nd Feb 2007 12:01 AM
Auto save replaced my original file and now I need the original? =?Utf-8?B?SG9scw==?= Microsoft Excel Misc 1 15th Aug 2005 10:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:02 AM.