Click here to Skip to main content
15,881,139 members
Home / Discussions / C#
   

C#

 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:36
sitebuilderLuc Pattyn17-Oct-09 13:36 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
CaptainSeeSharp17-Oct-09 13:43
CaptainSeeSharp17-Oct-09 13:43 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:53
sitebuilderLuc Pattyn17-Oct-09 13:53 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:47
sitebuilderLuc Pattyn17-Oct-09 13:47 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
harold aptroot17-Oct-09 14:09
harold aptroot17-Oct-09 14:09 
AnswerRe: Deleting objects from a collection Pin
dojohansen17-Oct-09 23:05
dojohansen17-Oct-09 23:05 
AnswerThanks everyone - results Pin
Trollslayer18-Oct-09 2:58
mentorTrollslayer18-Oct-09 2:58 
GeneralRe: Thanks everyone - results Pin
DaveyM6918-Oct-09 3:51
professionalDaveyM6918-Oct-09 3:51 
Trollslayer wrote:
ArrayList is not as efficient as List but I will use it for the output table list since it there will be a number of different table types and as long as they have a large number of common methods it is an easy method of keeping the tables in sequence


If it's just the common methods that you need to access via the array list then you can improve matters by using an interface and having a list of that.
C#
public interface ITable
{
    int IntProperty { get; set; }

    void RandomMethod();
}

public class TableA : ITable
{
    public int IntProperty
    {
        get;
        set;
    }

    public void RandomMethod()
    {
    }
}

public class TableB : ITable
{
    public int IntProperty
    {
        get;
        set;
    }
    public string StringProperty
    {
        get;
        set;
    }

    public void RandomMethod()
    {
    }
}
C#
/* Setting a suitable capacity here will improve things dramatically
* as if the list requires more space the entire list is copied to a new array.
* Luc has an article on his blog about this (IIRC) that is well worth reading. */
List<ITable> tableList = new List<ITable>(100);
tableList.AddRange(new ITable[]{
    new TableA(),
    new TableB()
});
// Each element in tableList will have IntProperty and RandomMethod


Dave

Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: Thanks everyone - results Pin
Trollslayer18-Oct-09 3:57
mentorTrollslayer18-Oct-09 3:57 
GeneralRe: Thanks everyone - results Pin
DaveyM6918-Oct-09 4:04
professionalDaveyM6918-Oct-09 4:04 
Questiongetting Bios date from c# in win64 environments Pin
Fred 3417-Oct-09 7:17
Fred 3417-Oct-09 7:17 
AnswerRe: getting Bios date from c# in win64 environments Pin
Abhijit Jana17-Oct-09 8:24
professionalAbhijit Jana17-Oct-09 8:24 
GeneralRe: getting Bios date from c# in win64 environments Pin
Fred 3417-Oct-09 9:09
Fred 3417-Oct-09 9:09 
GeneralRe: getting Bios date from c# in win64 environments Pin
Richard MacCutchan17-Oct-09 9:30
mveRichard MacCutchan17-Oct-09 9:30 
GeneralRe: getting Bios date from c# in win64 environments Pin
Abhijit Jana17-Oct-09 9:58
professionalAbhijit Jana17-Oct-09 9:58 
AnswerRe: getting Bios date from c# in win64 environments Pin
Vimalsoft(Pty) Ltd17-Oct-09 8:58
professionalVimalsoft(Pty) Ltd17-Oct-09 8:58 
AnswerRe: getting Bios date from c# in win64 environments Pin
dan!sh 17-Oct-09 9:49
professional dan!sh 17-Oct-09 9:49 
AnswerRe: getting Bios date from c# in win64 environments Pin
Dave Kreskowiak18-Oct-09 2:34
mveDave Kreskowiak18-Oct-09 2:34 
QuestionTextObject in CrystalReport Pin
ZeinabTavana17-Oct-09 6:52
ZeinabTavana17-Oct-09 6:52 
Questiongetting biosdate Pin
Fred 3417-Oct-09 5:58
Fred 3417-Oct-09 5:58 
AnswerRe: getting biosdate Pin
Not Active17-Oct-09 10:31
mentorNot Active17-Oct-09 10:31 
GeneralRe: getting biosdate Pin
Luc Pattyn17-Oct-09 12:17
sitebuilderLuc Pattyn17-Oct-09 12:17 
GeneralRe: getting biosdate Pin
Not Active17-Oct-09 16:21
mentorNot Active17-Oct-09 16:21 
QuestionWhile MouseDown Pin
Zap-Man17-Oct-09 3:27
Zap-Man17-Oct-09 3:27 
AnswerRe: While MouseDown Pin
Lyon Sun17-Oct-09 4:00
Lyon Sun17-Oct-09 4:00 

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.