From: Curious on
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;

}
}
From: Nobody on
"Curious" <fir5tsight(a)yahoo.com> wrote in message
news:bdc5ee7d-3437-4660-b94e-13de244b9bac(a)c10g2000yqi.googlegroups.com...
> // Use LINQ to get the subset that meets the criteria

This group is for VB6 and earlier(VB Classic). VB.Net and all dotnet groups
have either "dotnet" or "vsnet" in the group name. Please use the following
group instead:

news://news.aioe.org/microsoft.public.dotnet.languages.vb



From: Paul Clement on
On Mon, 9 Aug 2010 18:04:19 -0700 (PDT), Curious <fir5tsight(a)yahoo.com> wrote:

� 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;

� }
� }

Try posting your question to a C# forum:

http://social.msdn.microsoft.com/Forums/en/csharpgeneral/threads


Paul
~~~~
Microsoft MVP (Visual Basic)