<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Lou Haskett - All Comments</title><link>http://devlicio.us/blogs/louhaskett/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#62745</link><pubDate>Sun, 10 Oct 2010 02:03:26 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:62745</guid><dc:creator>Bin</dc:creator><description>&lt;p&gt;To David Muir,&lt;/p&gt;
&lt;p&gt;Your GetDerivedTypeList can pass the compiler check. But when called, the derived list returns all null properties for the individual list items (i.e. &amp;nbsp;x.PropertyA is null)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=62745" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#62209</link><pubDate>Wed, 15 Sep 2010 20:31:30 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:62209</guid><dc:creator>laneygourl</dc:creator><description>&lt;p&gt;anthropogenic ratified treaty&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=62209" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#61562</link><pubDate>Thu, 19 Aug 2010 22:35:36 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:61562</guid><dc:creator>carminatha</dc:creator><description>&lt;p&gt;percent paleoclimatology beta clathrate&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=61562" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#61450</link><pubDate>Thu, 12 Aug 2010 03:55:40 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:61450</guid><dc:creator>goldingtre</dc:creator><description>&lt;p&gt;intensity code mitigating scale&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=61450" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#59952</link><pubDate>Wed, 09 Jun 2010 03:35:13 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:59952</guid><dc:creator>diamontina</dc:creator><description>&lt;p&gt;societies president extinctions running issue impact beginning&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=59952" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#58951</link><pubDate>Tue, 18 May 2010 16:24:39 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:58951</guid><dc:creator>David Muir (david@tutorscotland.com)</dc:creator><description>&lt;p&gt;A problem that had me wondering for ages! The problem of generics and interfaces I guess. This is what I came up with as a solution. Hope it helps someone as I&amp;#39;m a bit out of date posting here.&lt;/p&gt;
&lt;p&gt;public static IList&amp;lt;TDerived&amp;gt; GetDerivedTypeList&amp;lt;TBase, TDerived&amp;gt;(this IList&amp;lt;TBase&amp;gt; baseList)&lt;/p&gt;
&lt;p&gt;	where TDerived : class, TBase&lt;/p&gt;
&lt;p&gt;	where TBase : class&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	return baseList.Where(x =&amp;gt; x != null).Select(x =&amp;gt; x as TDerived).ToList();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=58951" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#55861</link><pubDate>Thu, 11 Mar 2010 14:17:51 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:55861</guid><dc:creator>Sylvain AURAT</dc:creator><description>&lt;p&gt;As we can see previously, the better way to resolve this problem is certainely to use the proxy pattern (&lt;a rel="nofollow" target="_new" href="http://www.dofactory.com/Patterns/PatternProxy.aspx"&gt;www.dofactory.com/.../PatternProxy.aspx&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt; public static class CollectionUtil {&lt;/p&gt;
&lt;p&gt;	public static IList&amp;lt;TOutput&amp;gt; Cast&amp;lt;TInput, TOutput&amp;gt;(List&amp;lt;TInput&amp;gt; input) where TInput : TOutput {&lt;/p&gt;
&lt;p&gt;			if (typeof(TInput) == typeof(TOutput)) {&lt;/p&gt;
&lt;p&gt;				return (IList&amp;lt;TOutput&amp;gt;)input;&lt;/p&gt;
&lt;p&gt;			} else {&lt;/p&gt;
&lt;p&gt;				return new CastedListProxy&amp;lt;TInput, TOutput&amp;gt;(input);&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;internal class CastedListProxyEnumerator&amp;lt;TInput, TOutput&amp;gt;: IEnumerator&amp;lt;TOutput&amp;gt; where TInput : TOutput {&lt;/p&gt;
&lt;p&gt;	#region Fields declarations&lt;/p&gt;
&lt;p&gt;	private readonly IEnumerator&amp;lt;TInput&amp;gt;	_enumerator;&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Constructor declarations&lt;/p&gt;
&lt;p&gt;	public CastedListProxyEnumerator(CastedListProxy&amp;lt;TInput, TOutput&amp;gt; proxy) {&lt;/p&gt;
&lt;p&gt;		_enumerator = proxy.Source.GetEnumerator();&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Properties declarations&lt;/p&gt;
&lt;p&gt;	public TOutput Current {&lt;/p&gt;
&lt;p&gt;		get { return _enumerator.Current; }&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	object IEnumerator.Current {&lt;/p&gt;
&lt;p&gt;		get { return Current; }&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Methods declarations&lt;/p&gt;
&lt;p&gt;	public bool MoveNext() {&lt;/p&gt;
&lt;p&gt;		return _enumerator.MoveNext();&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void Reset() {&lt;/p&gt;
&lt;p&gt;		_enumerator.Reset();&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void Dispose() {&lt;/p&gt;
&lt;p&gt;		_enumerator.Dispose();&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;internal class CastedListProxy&amp;lt;TInput, TOutput&amp;gt; : IList&amp;lt;TOutput&amp;gt; where TInput : TOutput {&lt;/p&gt;
&lt;p&gt;	#region Constants declarations&lt;/p&gt;
&lt;p&gt;	private const string _READONLY_EXCEPTION_MESSAGE = &amp;quot;&amp;quot;;&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Fields declarations&lt;/p&gt;
&lt;p&gt;	private readonly IList&amp;lt;TInput&amp;gt; _src;&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Constructors declarations&lt;/p&gt;
&lt;p&gt;	public CastedListProxy(IList&amp;lt;TInput&amp;gt; source) {&lt;/p&gt;
&lt;p&gt;		_src = source;&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Properties declarations&lt;/p&gt;
&lt;p&gt;	public IList&amp;lt;TInput&amp;gt; Source {&lt;/p&gt;
&lt;p&gt;		get { return _src; }&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public int Count {&lt;/p&gt;
&lt;p&gt;		get { return _src.Count; }&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public bool IsReadOnly {&lt;/p&gt;
&lt;p&gt;		get { return true; }&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public TOutput this[int index] {&lt;/p&gt;
&lt;p&gt;		get { return _src[index]; }&lt;/p&gt;
&lt;p&gt;		set { throw new NotSupportedException(_READONLY_EXCEPTION_MESSAGE); }&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;	#region Methods declarations&lt;/p&gt;
&lt;p&gt;	public IEnumerator&amp;lt;TOutput&amp;gt; GetEnumerator() {&lt;/p&gt;
&lt;p&gt;		return new CastedListProxyEnumerator&amp;lt;TInput, TOutput&amp;gt;(this);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	IEnumerator IEnumerable.GetEnumerator() {&lt;/p&gt;
&lt;p&gt;		return GetEnumerator();&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public bool Contains(TOutput item) {&lt;/p&gt;
&lt;p&gt;		if (item is TInput) {&lt;/p&gt;
&lt;p&gt;			return _src.Contains((TInput)item);	&lt;/p&gt;
&lt;p&gt;		} else {&lt;/p&gt;
&lt;p&gt;			return false;&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void CopyTo(TOutput[] array, int arrayIndex) {&lt;/p&gt;
&lt;p&gt;		foreach (TInput entry in _src) {&lt;/p&gt;
&lt;p&gt;			array[arrayIndex] = entry;&lt;/p&gt;
&lt;p&gt;			arrayIndex++;&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public int IndexOf(TOutput item) {&lt;/p&gt;
&lt;p&gt;		throw new NotImplementedException();&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public bool Remove(TOutput item) {&lt;/p&gt;
&lt;p&gt;		throw new NotSupportedException(_READONLY_EXCEPTION_MESSAGE);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void Add(TOutput item) {&lt;/p&gt;
&lt;p&gt;		throw new NotSupportedException(_READONLY_EXCEPTION_MESSAGE);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void Clear()&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		throw new NotSupportedException(_READONLY_EXCEPTION_MESSAGE);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void Insert(int index, TOutput item) {&lt;/p&gt;
&lt;p&gt;		throw new NotSupportedException(_READONLY_EXCEPTION_MESSAGE);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	public void RemoveAt(int index) {&lt;/p&gt;
&lt;p&gt;		throw new NotSupportedException(_READONLY_EXCEPTION_MESSAGE);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	#endregion&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55861" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#54543</link><pubDate>Tue, 15 Dec 2009 15:51:36 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:54543</guid><dc:creator>aethelbeor</dc:creator><description>&lt;p&gt;rise geoengineering economists stricter offset tonne&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54543" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#54322</link><pubDate>Sat, 05 Dec 2009 01:56:08 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:54322</guid><dc:creator>truesdellf</dc:creator><description>&lt;p&gt;period particularly amount exempt&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54322" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#54133</link><pubDate>Thu, 26 Nov 2009 02:47:21 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:54133</guid><dc:creator>arnellemor</dc:creator><description>&lt;p&gt;notes agree pollution broadly inc&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54133" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#54048</link><pubDate>Mon, 23 Nov 2009 12:22:11 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:54048</guid><dc:creator>Filipe Belchior</dc:creator><description>&lt;p&gt;Vinod Joseph,&lt;/p&gt;
&lt;p&gt;i am with this exactly problem. but your solution dont work. help, please, some?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=54048" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#52955</link><pubDate>Thu, 22 Oct 2009 16:28:17 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:52955</guid><dc:creator>Vinod Joseph</dc:creator><description>&lt;p&gt;//List&amp;lt;IBase&amp;gt; myInheritedClassList = GetList();&lt;/p&gt;
&lt;p&gt;//List&amp;lt;MyInheritedClass&amp;gt; myNewInheritedClassList = new List&amp;lt;MyInheritedClass&amp;gt;((MyInheritedClass[]) myInheritedClassList.ToArray());&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=52955" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#52883</link><pubDate>Wed, 21 Oct 2009 15:48:56 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:52883</guid><dc:creator>Cameron</dc:creator><description>&lt;p&gt;Matt, sweet... there you go. &amp;nbsp;LINQ to the rescue&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=52883" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#52410</link><pubDate>Wed, 07 Oct 2009 23:39:01 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:52410</guid><dc:creator>Matt</dc:creator><description>&lt;p&gt;Perhaps LINQ could help. Something along the lines of&lt;/p&gt;
&lt;p&gt;shapes = (from c in circles select s as Shape).ToList();&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=52410" width="1" height="1"&gt;</description></item><item><title>re: How-To: "Cast" between List&lt;T&gt;'s</title><link>http://devlicio.us/blogs/louhaskett/archive/2007/06/13/how-to-cast-between-list-t-s.aspx#44039</link><pubDate>Sun, 08 Feb 2009 18:18:47 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:44039</guid><dc:creator>Ankush Bindlish</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I didnt get anything from the above story.&lt;/p&gt;
&lt;p&gt;I have a memory of list&amp;lt;TypeA&amp;gt; which need to be referenced conversion(boxing conversion) to List&amp;lt;TypeB&amp;gt;&lt;/p&gt;
&lt;p&gt;Solution 1 : &amp;nbsp;Iterate and typecast each member suing &amp;quot;as&amp;quot; keyword in c#, or use language specific typecast)&lt;/p&gt;
&lt;p&gt;- backup solution if you wont find any.&lt;/p&gt;
&lt;p&gt;Solution 2 (which is not working for me)&lt;/p&gt;
&lt;p&gt;List&amp;lt;TypeA&amp;gt; points&lt;/p&gt;
&lt;p&gt;List&amp;lt;TypeB&amp;gt; Bpoints = Apoints as List&amp;lt;TypeB&amp;gt;&lt;/p&gt;
&lt;p&gt;Please let me know if anyone knows it to have a boxed type conversion.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=44039" width="1" height="1"&gt;</description></item></channel></rss>
