<?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>johnjcamilleri.com &#187; dictionary</title>
	<atom:link href="http://johnjcamilleri.com/tag/dictionary/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnjcamilleri.com</link>
	<description></description>
	<lastBuildDate>Fri, 03 Sep 2010 13:00:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Returning Key/Value pairs from a .NET Web Service</title>
		<link>http://johnjcamilleri.com/2009/04/returning-keyvalue-pairs-from-a-net-web-service/</link>
		<comments>http://johnjcamilleri.com/2009/04/returning-keyvalue-pairs-from-a-net-web-service/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 16:51:41 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[pair]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[value]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://www.johnjcamilleri.com/blog/?p=23</guid>
		<description><![CDATA[As soon as I started using Web Services I came against this problem, and loads of other people have asked it before but I didn&#8217;t really find a satisfactory answer. The easiest method is to create your own custom class (or a struct, as I did) and use that: The struct public struct KeyValueStruct { [...]]]></description>
			<content:encoded><![CDATA[<p>As soon as I started using Web Services I came against this problem, and loads of other people have asked it before but I didn&#8217;t really find a satisfactory answer. The easiest method is to create your own custom class (or a struct, as I did) and use that:</p>
<p><strong>The struct</strong></p>
<pre>
public struct KeyValueStruct
{
private int _key;
private string _val;

public int Key
{
get { return _key; }
set { _key = value; }
}
public string Value
{
get { return _val; }
set { _val = value; }
}

public KeyValueStruct(int key, string value)
{
_key = key;
_val = value;
}
}
</pre>
<p><strong>The web method</strong></p>
<pre>
[WebMethod]
[XmlInclude(typeof(KeyValueStruct))]
public List&lt;KeyValueStruct&gt;  GetEnergySources()
{
List&lt;KeyValueStruct&gt;  sources = new List&lt;KeyValueStruct&gt;();
sources.Add(new KeyValueStruct(1, "Solar"));
sources.Add(new KeyValueStruct(2, "Wind"));
return sources;
}
</pre>
<p>Simple!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnjcamilleri.com/2009/04/returning-keyvalue-pairs-from-a-net-web-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
