|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Collection findall errordo it this way: TableColumnNameCollection tcn = AppSettings.tableColumnNames.FindAll(delegate(TableColumnName tcn1) { return tcn1.TableName == strTemp; }); But I can do it this way: List<TableColumnName> tcn = AppSettings.tableColumnNames.FindAll(delegate(TableColumnName tcn1) { return tcn1.TableName == strTemp; }); My class is: ********************************************** using System; using System.Collections.Generic; using System.Text; namespace RepositoryServiceApp.BusinessLayer { public class TableColumnName { private string mstrTableName; private string mstrColumnName; private string mstrColumnType; public string ColumnType { get { return mstrColumnType; } set { mstrColumnType = value; } } public string ColumnName { get { return mstrColumnName; } set { mstrColumnName = value; } } public string TableName { get { return mstrTableName; } set { mstrTableName = value; } } public new string ToString() { return TableName + " / " + ColumnName + " / " + ColumnType; } } public class TableColumnNameCollection : List<TableColumnName> { } } ******************************************************* Why can't I use TableColumnNameCollection in my Findall statement? Isn't it the same as List<TableColumnName>? Thanks, Tom
Show quote
Hide quote
"tshad" <t**@dslextreme.com> wrote in message TableColumnNameCollection is not "the same as" a List<TableColumnName>.news:eWFBKwHYJHA.2068@TK2MSFTNGP03.phx.gbl... >I am using FindAll to get a set of my TableColumnNames and get an error if >I do it this way: > > TableColumnNameCollection tcn = > > AppSettings.tableColumnNames.FindAll(delegate(TableColumnName tcn1) > { return tcn1.TableName == strTemp; }); > > But I can do it this way: > > List<TableColumnName> tcn = > > AppSettings.tableColumnNames.FindAll(delegate(TableColumnName tcn1) > { > return tcn1.TableName == strTemp; }); > > My class is: > ********************************************** > using System; > using System.Collections.Generic; > using System.Text; > > namespace RepositoryServiceApp.BusinessLayer > { > public class TableColumnName > { > private string mstrTableName; > private string mstrColumnName; > private string mstrColumnType; > > public string ColumnType > { > get { return mstrColumnType; } > set { mstrColumnType = value; } > } > > public string ColumnName > { > get { return mstrColumnName; } > set { mstrColumnName = value; } > } > > public string TableName > { > get { return mstrTableName; } > set { mstrTableName = value; } > } > > public new string ToString() > { > return TableName + " / " + ColumnName + " / " + ColumnType; > } > } > public class TableColumnNameCollection : List<TableColumnName> { } > } > ******************************************************* > > Why can't I use TableColumnNameCollection in my Findall statement? > > Isn't it the same as List<TableColumnName>? > TableColumnNameCollection is a List<TableColumnName> in the sense that its a subclass of List<TableColumnName>. Hence its possible to assign a TableColumnNameCollection to a List<TableColumnName> since we know all TableColumnNameCollection are List<TableColumnName>. OTH its not possible to assign List<TableColumnName> to a TableColumnNameCollection because not all List<TableColumnName> are TableColumnNameCollection. The FindAll in this case is creating an instance of List<TableColumnName> not an instance of TableColumnNameCollection hence you will not be able to assign it such, even with an explicit cast. -- Anthony Jones - MVP ASP/ASP.NET
replacing characters in a string
Draw vertical text? syntax for app.startuppath to move back one folder Port DllImport from VB to C# about a query with linq Localization / Globalization / language versions - Where to start? Bind event to Datagridview - where's list of events? LINQ to SQL Classes question .NET Remoting 101 UDPClient problem (broadcast and multiple network adapters.) |
|||||||||||||||||||||||