C # Generics

E

Elliott810

I have to be honest I haven't used many generics in my coding; I
really want to start using more of them but am having trouble with
what is the best way to use a generic with my Send method because the
Send method needs to point to different data factories. I really would
like to hear some suggestions.

using System;
using System.Collections;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Xml;

namespace PartsNow.Site.Database.Data
{
public class Groups
{
#region Fields
ArrayList m_items = new ArrayList();
#endregion

#region Properties
public virtual Group this[int index]
{
get
{
return (Group)m_items[index];
}
}
#endregion

#region Constructors
public Groups(Group[] objs)
{
foreach (Group obj in objs)
{
this.List.Add(obj);
}
}

internal Groups(SqlDataReader dbReader)
{
while (dbReader.Read())
{
m_items.Add(new Group(dbReader));
}
}
#endregion

#region Methods
public virtual void Add(Group obj)
{
this.List.Add(obj);
}

public virtual Group[] ToArray()
{
return (Group[])m_items.ToArray(typeof(Group));
}

public void Send()
{
SqlDataRecord dbRecord = new
SqlDataRecord(Factory.Catalog.MetaData);

SqlContext.Pipe.SendResultsStart(dbRecord);

foreach (Catalog catalog in base.List)
{
Factory.Catalog.SendResultsRow(catalog, dbRecord);
}

SqlContext.Pipe.SendResultsEnd();
}
#endregion
}
}
 
B

Brian Muth

I'm sure you will get a better response in a C# newsgroup, rather than a C++ newsgroup. Try reposting in
microsoft.public.dotnet.languages.csharp.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top