In the interest of code re-use, I would like to place some code in a utility
class to be used by other classes. The problem is that this code requires
the following snippet:
for(i=0; i < tbl.Rows.Count; i++)
{
myDataRow = tbl.Rows[i];
company.someNes tedClass sc = new company.someNes tedClass();
for(j=0; j < tbl.Columns.Cou nt; j++)
{
sc.someProperty = Convert.ToBoole an(myDataRow.It emArray[0]);
sc.anotherPrope rty = Convert.ToBoole an(myDataRow.It emArray[1]);
}
myHash.Add(some Key, sc);
}
how can I make company.someNes tedClass sc = new company.someNes tedClass();
into something more generic/variable/unspecific?
Also, can you cast to a cast variable of some sort, so that you don't have
to know, until runtime, what you want to cast to?
As it is, I have to put this code in every class I wish to apply it to.
Thanks in advance.
class to be used by other classes. The problem is that this code requires
the following snippet:
for(i=0; i < tbl.Rows.Count; i++)
{
myDataRow = tbl.Rows[i];
company.someNes tedClass sc = new company.someNes tedClass();
for(j=0; j < tbl.Columns.Cou nt; j++)
{
sc.someProperty = Convert.ToBoole an(myDataRow.It emArray[0]);
sc.anotherPrope rty = Convert.ToBoole an(myDataRow.It emArray[1]);
}
myHash.Add(some Key, sc);
}
how can I make company.someNes tedClass sc = new company.someNes tedClass();
into something more generic/variable/unspecific?
Also, can you cast to a cast variable of some sort, so that you don't have
to know, until runtime, what you want to cast to?
As it is, I have to put this code in every class I wish to apply it to.
Thanks in advance.
Comment