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 8253987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:03:53+00:00 2026-06-08T01:03:53+00:00

I tried the solution below but I don’t like it. I am looking for

  • 0

I tried the solution below but I don’t like it. I am looking for extending the class, not encapsulating a double[].

Thanks.

EDIT: We need to work with .NET 2.0

public class DoubleArray : IList, ICloneable
{

    protected double[] items;

    /// <summary>
    /// Gets the last item in the array.
    /// </summary>
    public double Last { get { return items[items.Length-1]; } }

    /// <summary>
    /// Gets the number of items in the array.
    /// </summary>
    public int Length { get { return items.Length; } }

    /// <summary>
    /// Number of items constructor.
    /// </summary>
    /// <param name="len">Number of items</param>
    public DoubleArray(int len)
    {
        items = new double[len];
    }      

    public double this[int index]
    {
        get { return items[index]; }
        set { items[index] = value; }
    }

    public bool IsReadOnly
    {
        get { return items.IsReadOnly; }
    }

    public bool IsFixedSize
    {
        get { return items.IsFixedSize; }
    }

    public void CopyTo(Array array, int index)
    {
        items.CopyTo(array, index);
    }

    public IEnumerator GetEnumerator()
    {
        return items.GetEnumerator();
    }

    public object SyncRoot
    {
        get { return items.SyncRoot; }
    }

    public bool IsSynchronized
    {
        get { return items.IsSynchronized; }
    }

    object ICloneable.Clone()
    {
        return items.Clone();
    }

    #region ICollection and IList members implementation

    // hides this members from intellisense, see: http://stackoverflow.com/questions/10110205/how-does-selectedlistviewitemcollection-implement-ilist-but-not-have-add

    int ICollection.Count
    {
        get { return items.Length; }
    }

    int IList.Add(object value)
    {
        throw new NotImplementedException();
    }

    bool IList.Contains(object value)
    {
        throw new NotImplementedException();
    }

    void IList.Clear()
    {
        throw new NotImplementedException();
    }

    int IList.IndexOf(object value)
    {
        throw new NotImplementedException();
    }

    void IList.Insert(int index, object value)
    {
        throw new NotImplementedException();
    }

    void IList.Remove(object value)
    {
        throw new NotImplementedException();
    }

    void IList.RemoveAt(int index)
    {
        throw new NotImplementedException();
    }

    object IList.this[int index]
    {
        get { throw new NotImplementedException(); }
        set { throw new NotImplementedException(); }
    } 

    #endregion

}
  • 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-08T01:03:53+00:00Added an answer on June 8, 2026 at 1:03 am

    Here is a solution that satisfies me. C# 3.0 Extensions can be used in .NET 2.0 simply adding this code:

    #if NET20
    namespace System.Runtime.CompilerServices
    {
        [AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
         public class ExtensionAttribute : Attribute
        {
        }
    }
    #endif
    

    Afterwards you can use the following extension method (and many others):

    public static class DoubleArrayExtension
    {
        // This is the extension method.
        // The first parameter takes the "this" modifier
        // and specifies the type for which the method is defined.       
        public static double Last(this double[] items)
        {
            return items[items.Length - 1];
        }
    
    }
    

    Thanks for all your hints and suggestions guys!

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

Sidebar

Related Questions

I've tried the solution here , but it doesn't work. My table is like
I tried the solution from this thread , but I must be missing something
I tried multiple solution but none seem to work. Layout: -------------------- |btn1| txt1 |btn2|
hello i am having same issue, i tried your solution but it didnt help
I tried to find a solution but I didn't found what I was searching
I have tried to look everywhere for a solution but I can't seem to
Probably a simple solution, but i don't get it working. I have a table
gem install heroku failed with following message and I have tried the solution here
I'm trying to remove scrollbar from my facebook app. I tried js solution, that
I tried to find a solution to my problem already in google and here

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.