TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Swift and C# Quick Reference – Language Equivalents and Code Examples [pdf]

66 点作者 masters3d大约 10 年前

8 条评论

ianhedoesit大约 10 年前
I can&#x27;t find an accompanying article or anything for this. I&#x27;m curious as to why Microsoft would put something like this out? Why make the comparison in the first place? Why compare it to Swift?<p>Also, the code at <a href="http://aka.ms/scspostercode" rel="nofollow">http:&#x2F;&#x2F;aka.ms&#x2F;scspostercode</a> is nice.
评论 #9125471 未加载
评论 #9125858 未加载
评论 #9125449 未加载
alkonaut大约 10 年前
If you find the &quot;classes&quot; section makes no sense, it&#x27;s because the heading column is one line out of sync with the other columns.
Alphasite_大约 10 年前
What I find strange is that some of these examples dont even do the same thing, which is a little odd when you&#x27;re trying to do a fair comparison. And some weird non optimal syntax on both sides.<p>Im also a not a fan of the pure white, but thats quite a minor complaint.
rdavisau大约 10 年前
I went to an &#x27;Azure Mobile DevCamp&#x27; event for iOS a couple of days ago. It was sponsored by Microsoft but run by someone otherwise unaffiliated who ran a mobile development shop coding in each platform&#x27;s native language.<p>The session was interactive&#x2F;follow along, the instructor led in swift and I decided to try following along using C#&#x2F;Xamarin iOS (disclosure: I use Xamarin.iOS daily and am a big fan of C#). On iOS I had worked for a couple of years in obj-c before moving to Xamarin, but hadn&#x27;t touched swift. Having read comparison articles similar to this, my otherwise uninformed opinion was that swift looked to provided a far more reasonable experience, similar to C# - to the point that I wondered whether it was worth paying the fee for Xamarin to avoid the archaic objective c language. However, there were a few things from the demo that changed my mind (some are apple ecosystem, some are swift):<p>- no first class support for package management, and adding references to to libraries by hand can still be error prone and frustrating. We spent 10 minutes getting the room set up with their cocoapods - lucky me I had NuGet and in a few clicks had the packages installed. - no `await`-style capability - it seems small but nested callbacks is not something I want to have to deal with anymore, and it makes certain patterns unwieldy. - no LINQ query provider style support - making a call to the azure mobile service with a filter and sort clauses required newing up awkward predicate and sort objects and attaching them to a query before running (which then, again, required a callback!). In C# you could use the same syntax you would use if the collection were local - `await table.Where(i=&gt; i.Name.Contains(&quot;Bob&quot;)).OrderBy(i=&gt; i.LastName).ToListAsync()` - and the clauses would be transparently translated into parameters for the service call. - Lots of &quot;crashes&quot; in the IDE while writing swift code, where the compiler would bomb out and syntax highlighting etc. would be disabled while it sorted itself out again.<p>Swift still seems to be a huge improvement over obj-c, and some of these will be improved as time goes by, but fundamental features like await make a big difference, especially working on mobile where you are often waiting on network calls, user activity etc. And that&#x27;s all before you even touch the topic of code sharing.
评论 #9126559 未加载
mythz大约 10 年前
As it&#x27;s relevant, ServiceStack also provides integration with XCode that lets you generate a typed API for easily consuming C# JSON Web Services in Swift iOS&#x2F;OSX Apps:<p><a href="https://github.com/ServiceStack/ServiceStack/wiki/Swift-Add-ServiceStack-Reference" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ServiceStack&#x2F;ServiceStack&#x2F;wiki&#x2F;Swift-Add-...</a>
masters3d大约 10 年前
I made a couple of tables to keep track of the changes to swift <a href="https://github.com/masters3d/SwiftCSharp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;masters3d&#x2F;SwiftCSharp</a>
thejew大约 10 年前
Swift has internal now.
评论 #9125608 未加载
_random_大约 10 年前
Beautiful presentation.