Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Function explanation c#

Posted on 2011-03-07
4
Medium Priority
?
228 Views
Last Modified: 2012-05-11
Hello all,

I am using a class that i downloaded from: http://www.codeproject.com/KB/recipes/K-Mean_Clustering.aspx

And in the class Kmeans. They say that this function:

/// <summary>
            /// Returns the one dimensional array data located at the index
            /// </summary>
            public virtual double [] this[int Index]
            {
                  get
                  {
                        //return the Neuron at IList[Index]
                        return (double[])this.List[Index];      
                  }    
            }
I don't understand how to get the list. it's the first time that i see this in c# i am really new. Thank you.
0
Comment
Question by:dadadude
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 35063043
In looking at that definition, what I see is the class KMeans is a class which implements IEnumerable, meaning it can be indexed. Think of it basically as an array itself. This "array" holds lists of doubles in each of its slots. When you have an instance of this class:

    KMeans instance = new KMeans();

you can treat it like an array and index it:

    double[] aList = instance[0];
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35063048
Actually, I made an assumption that it implements IEnumerable--that may or may not be accurate. The concept of treating it like an array still applies though.
0
 
LVL 1

Expert Comment

by:lalitgada
ID: 35067886
crate an object of Ilist
and return that object.
0
 

Author Comment

by:dadadude
ID: 35068169
yes Thank you, Kaufmed. Actually i managed to understand it. thank you for your explanation. It was just a list of double. But the way that it is written is new for me.

Thanks again.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question