Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:04:30+00:00 2026-06-14T03:04:30+00:00

I’m trying to create a wrapper around List to do some specific things I

  • 0

I’m trying to create a wrapper around List to do some specific things I want, such as compute max min, extract specific values from some elements, etc.

I start with

    public struct datum {
      public UInt32[] chan;
      public UInt64 sample_number;
      public UInt32 time;
      public UInt32 source_sector;
    } 

    public class dataSet : List<datum> {
     bool dirty=true;
     ....
    }

the methods are typically like this (I want to know if the list has been modified as I have a max()/min() function that only parses the data when it has been modified and caches the values to reuse if the List has not been modified)

     public new void Add(datum x ) {
        base.Add(x);
        this.dirty = true;
    }

However, I’m not sure how to create a constructor. This syntax does not work.. how can I get this type of behavior?

    public dataSet(int count) {
        this = (dataSet) new List<datum>(count);
    }

I also have this constructor, which seems to work fine (no compilation errors) though untested

    public dataSet(List<datum> data) {
        this.AddRange(data);
    }

I came across a post that said that you should use a Collection and a List is used for speed. Though I need the speed, and I’m not sure why a Collection would be better?

–UPDATE–

I don’t want to use linq as you can’t create something that computes max/min simultaneously as efficiently as this:

    public void recalculateMaxMin() {
        foreach (var d in data) {
            for (int i = 0; i < 16; i++) {
                if (d.chan[i] > max[i]) max[i] = d.chan[i];
                if (d.chan[i] < min[i]) min[i] = d.chan[i];
            }
        }
    }

Thnx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:04:32+00:00Added an answer on June 14, 2026 at 3:04 am

    You can never ever set "this" to something in C#. I think you are looking for this:

    public dataSet(int count)
         : base(count)
    { }
    

    However in my opinion you should take a look at "System.Linq" namespace. I think what you are trying to implement has been done before by Microsoft. ‘Select’, ‘Join’, ‘Where’ and many other clauses has been already implemented in Linq. Also you can use "INotifyCollectionChanged" interface to implement the dirty thing.

    Here are some references:

    1. INotifyCollectionChanged
    2. Linq

    If you realy need to implement a complete List class with a new behavior, implementing "System.Collections.Generic.IList" interface is the only thing that will rock your idea in an advanced and perfect way. It’s more customizable than inheriting from the List class and trying to change everything you have no access to.

    Hope it helps

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.