<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wcode.net &#187; method</title>
	<atom:link href="http://wcode.net/tag/method/feed/" rel="self" type="application/rss+xml" />
	<link>http://wcode.net</link>
	<description>Article and Personal Blog</description>
	<lastBuildDate>Tue, 24 Nov 2009 10:51:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create Array Parameters in C#</title>
		<link>http://wcode.net/2009/11/create-array-parameters-in-c/</link>
		<comments>http://wcode.net/2009/11/create-array-parameters-in-c/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 15:20:58 +0000</pubDate>
		<dc:creator>Willy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[KNN]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[Nearest Neighbor]]></category>
		<category><![CDATA[Object]]></category>
		<category><![CDATA[Parameters]]></category>

		<guid isPermaLink="false">http://wcode.net/?p=75</guid>
		<description><![CDATA[Today i have request from &#8216;bad friend&#8217; code name &#8216;mashudi&#8217; to create Nearest Neighbor Class, Artificial Intelegent system that can compute distance from one to other node.
From this project I will share how to create a constructor or maybe you need for method that use array parameters.
Design of implementation in KNN node class will be [...]]]></description>
			<content:encoded><![CDATA[<p>Today i have request from &#8216;bad friend&#8217; code name &#8216;mashudi&#8217; to create Nearest Neighbor Class, Artificial Intelegent system that can compute distance from one to other node.</p>
<p>From this project I will share how to create a constructor or maybe you need for method that use array parameters.</p>
<p>Design of implementation in KNN node class will be like this :</p>
<pre class="brush:csharp">
KNNNode node1 = new KNNNode("Rose", 2.5, 4, 4.2);
KNNNode node2 = new KNNNode("Height", 2.5, 4, 4.2, 4.5, 6.3);
</pre>
<p>So you can add more parameters to that class.</p>
<p><span id="more-75"></span></p>
<p>Here my code in KNNNode class :</p>
<pre class="brush:csharp">

using System.Collections.Generic;

namespace Algorithm.KNN
{
    public class KNNNode
    {
        List<float> val;
        string label;

        public string Label
        {
            get { return label; }
            set { label = value; }
        }

        // 'params float[] val' it will create array parameters
        public KNNNode(string label, params float[] val)
        {
            //set label
            this.label = label;
            //Set actual size of val
            this.val = new List<float>(val.Length); 

            //iterate from first to last argument
            //and fill to list
            foreach (float v in val)
            {
                this.val.Add(v);
            }
        }

        public int Count
        {
            get {
                return val.Count;
            }
        }

        //prevent default constructor inisialization
        private KNNNode()
        { }

        //Direct access to list value
        public float this[int index]
        {
            get { return val[index]; }
            set { val[index] = value; }
        }
    }
}
</pre>
<p>Hope it&#8217;s help<br />
Willy Achmat Fauzi</p>
]]></content:encoded>
			<wfw:commentRss>http://wcode.net/2009/11/create-array-parameters-in-c/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
