tag:blogger.com,1999:blog-2458417257543687994.post1076038320299099032..comments2024-01-26T11:22:48.245-07:00Comments on Loyc, etc.: D-style ranges in C# (.NET)Qwertiehttp://www.blogger.com/profile/04595705428290721343noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2458417257543687994.post-5652194074096682222015-12-23T03:34:44.267-07:002015-12-23T03:34:44.267-07:00This comment has been removed by a blog administrator.navyahttps://www.blogger.com/profile/09650347706574609617noreply@blogger.comtag:blogger.com,1999:blog-2458417257543687994.post-74538088680128658542013-12-04T16:59:41.454-07:002013-12-04T16:59:41.454-07:00someCollection.OfType().ToList() in linq, but not ...someCollection.OfType().ToList() in linq, but not with his interfaces...<br />impl:<br />foreach(var item in source)<br /> if(item is T)<br /> yield return (T)item; //cannot use as with genericsAnonymoushttps://www.blogger.com/profile/08905354729835009969noreply@blogger.comtag:blogger.com,1999:blog-2458417257543687994.post-16364146425296564452013-06-03T09:51:03.978-06:002013-06-03T09:51:03.978-06:00Yes, I am a believer in interfaces that only defin...Yes, I am a believer in interfaces that only define one or two methods or add one or two methods on top of an existing interface. But I'd rather have go-style interfaces.<br /><br />I am not sure what you mean about As(), but there are extension methods such as AsListSource() and AsList() to convert between old and new interfaces. And EC# defines a new form of the 'as' and cast operator '->' which is more fluent, as well as a third cast operator.<br /><br />Foo(as IBar).Bar()<br />objectList[i](->string).Length<br /><br />And I think I'll rename IListSource to IReadList in light of the new IReadOnlyList in .NET 4.5. IReadList has two methods that IReadOnlyList does not have, and the name 'IReadOnlyList' isn't fully appropriate because although the interface provides only read-only access, that doesn't mean that the list is actually read-only. It could still be writable--just not by you.Qwertiehttps://www.blogger.com/profile/04595705428290721343noreply@blogger.comtag:blogger.com,1999:blog-2458417257543687994.post-75309696825713150842013-06-03T03:47:31.305-06:002013-06-03T03:47:31.305-06:00Small, specific interfaces. I read something once ...Small, specific interfaces. I read something once that suggested that it would have been a Good Thing if interfaces could only have one member (but could still inherit).<br /><br />As for your adapter types/coercion methods, do you have something like <br /><br />var countable = someCollection.As(), which one could use instead of the standard as/is operators?<br /><br />These would be handy if I was wanting to write some code that was optimised for types with adapters.Harry McIntyrehttps://www.blogger.com/profile/16748782353710296964noreply@blogger.comtag:blogger.com,1999:blog-2458417257543687994.post-26156575933670700332013-06-02T10:50:13.780-06:002013-06-02T10:50:13.780-06:00Not before I wrote the article, no.Not before I wrote the article, no.Qwertiehttps://www.blogger.com/profile/04595705428290721343noreply@blogger.comtag:blogger.com,1999:blog-2458417257543687994.post-26834498907069133792013-06-02T04:07:30.534-06:002013-06-02T04:07:30.534-06:00I am just curious, have you seen this: http://msdn...I am just curious, have you seen this: http://msdn.microsoft.com/en-us/library/hh881542.aspx ?Anonymousnoreply@blogger.com