Solved

Function explanation c#

Posted on 2011-03-07
4
219 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 74

Accepted Solution

by:
käµfm³d   👽 earned 500 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 74

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now