Click here to Skip to main content
15,888,984 members
Home / Discussions / C#
   

C#

 
GeneralRe: ini file Pin
faheemnadeem8-Sep-09 18:38
faheemnadeem8-Sep-09 18:38 
GeneralRe: ini file Pin
Member 5903108-Sep-09 18:41
Member 5903108-Sep-09 18:41 
QuestionControlling Wireless and GPRS programmatically Pin
arimao8-Sep-09 15:16
arimao8-Sep-09 15:16 
AnswerRe: Controlling Wireless and GPRS programmatically Pin
arimao9-Sep-09 1:49
arimao9-Sep-09 1:49 
AnswerRe: Controlling Wireless and GPRS programmatically Pin
rodrigo_melo10-Apr-10 7:27
rodrigo_melo10-Apr-10 7:27 
QuestionMultithreaded UDP listener in c# Pin
Christian_V_V8-Sep-09 14:39
Christian_V_V8-Sep-09 14:39 
AnswerRe: Multithreaded UDP listener in c# Pin
N a v a n e e t h8-Sep-09 16:55
N a v a n e e t h8-Sep-09 16:55 
QuestionGenerics [modified] Pin
Daniel.J.A8-Sep-09 13:52
Daniel.J.A8-Sep-09 13:52 
Hello.

I have not found any information on this part as of yet, and I need a little bit of help.

What I have done is I have my base class that has a bunch of properties and for each property I have a attribute on it. I have other classes that will inherit this class

<pre>public abstract class MyBaseClass : IEnumerable
{
      protected bool m_TableName;
      protected Guid m_ID;
      protected string m_DisplayName;

      //CustomProperty is in the format "Field Name", Display in the grid, Database field
      [CustomProperty("TableName", false, true)]
      public string TableName
      {
            get{return m_TableName;}
            set{m_TableName = value;}
      }
     
      [CustomPropety("ID", false, true)]
      public Guid ID
      {
            get{return m_ID;}
            set{m_ID = value;}
      }
      ...
}</pre>

Now here is my next class which will be where I store my collection of classes
<pre>public abstract class MyTableObject<T> : IEnumerable<T> where T: MyBaseClass
{
      protected List<T> m_Rows = new List<T>();
      protected SQLConnection m_conn;
      //other methods and variable not needed for my example
      ...

      protected AddNewRow(T newItem)
      {
            m_Rows.Add(newItem);
      }
      protected FillData(SQLCommand newCmd)
      {
            DataTable dt = New DataTable();
            using(SqlDataAdapter da = new SqlDataAdapter(newCmd))
            {
               da.Fill(dt);
               foreach(DataRow dr in dt.Rows)
               {
                     AddNewRow(???);
                     //now what I need to do is basically a T tmp = new T(); AddNewRow(tmp);
                     //but you can not do that it errors out.
                     //other code under her for adding all the fields.
                     //Also have a similar one for building a select statement, base insert, base update statements
               }
            }
      }
}</pre>


Any help on this would greatly be appreciated.
The MyTableObject is the base object that all my other table object will inherit so I do not want to do the fill code at any higher lever

Thanks

modified on Tuesday, September 8, 2009 8:05 PM

AnswerRe: Generics Pin
Christian Graus8-Sep-09 13:59
protectorChristian Graus8-Sep-09 13:59 
AnswerRe: Generics Pin
Luc Pattyn8-Sep-09 14:04
sitebuilderLuc Pattyn8-Sep-09 14:04 
AnswerRe: Generics Pin
N a v a n e e t h8-Sep-09 16:36
N a v a n e e t h8-Sep-09 16:36 
AnswerRe: Generics Pin
Daniel.J.A28-Sep-09 12:16
Daniel.J.A28-Sep-09 12:16 
Questionhow to create a tool item dropdown menu with C#? Pin
iozk8-Sep-09 12:20
iozk8-Sep-09 12:20 
AnswerRe: how to create a tool item dropdown menu with C#? Pin
Christian Graus8-Sep-09 12:31
protectorChristian Graus8-Sep-09 12:31 
QuestionOdd Visual Studio 2005 behaviour when adding Object Data Source [modified] Pin
Martijn Boeker8-Sep-09 12:10
Martijn Boeker8-Sep-09 12:10 
QuestionSubreports Pin
mbangh8-Sep-09 12:05
mbangh8-Sep-09 12:05 
AnswerRe: Subreports Pin
Mycroft Holmes8-Sep-09 15:59
professionalMycroft Holmes8-Sep-09 15:59 
QuestionNetworking problems. Pin
CRAZYCRICKET2258-Sep-09 9:19
CRAZYCRICKET2258-Sep-09 9:19 
GeneralRe: Networking problems. Pin
harold aptroot8-Sep-09 10:40
harold aptroot8-Sep-09 10:40 
AnswerRe: Networking problems. Pin
Luc Pattyn8-Sep-09 14:08
sitebuilderLuc Pattyn8-Sep-09 14:08 
GeneralRe: Networking problems. Pin
CRAZYCRICKET2258-Sep-09 21:36
CRAZYCRICKET2258-Sep-09 21:36 
GeneralRe: Networking problems. Pin
CRAZYCRICKET2259-Sep-09 0:26
CRAZYCRICKET2259-Sep-09 0:26 
GeneralRe: Networking problems. Pin
Luc Pattyn9-Sep-09 12:29
sitebuilderLuc Pattyn9-Sep-09 12:29 
QuestionC# Pin
aayshasid8-Sep-09 9:18
aayshasid8-Sep-09 9:18 
AnswerRe: C# Pin
Not Active8-Sep-09 9:22
mentorNot Active8-Sep-09 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.