Code Monkey home page Code Monkey logo

swiftcsharp's Introduction

SwiftCSharp

Comparing Swift and C#

"Swift and C# Quick Reference – Language Equivalents and Code Examples"

Reference http://download.microsoft.com/download/4/6/9/469501F4-5F6B-4E51-897C-9A216CFB30A3/SwiftCSharpPoster.pdf

Variables Swift C#
boolean Bool bool
constant let const
declaration var var
float Float, Double float, double
integer Int int
optional value type ? (optional) ? (nullable)
optional ref type ? (optional) planned
tuple tuple System.Tuple
string String (value) string (reference)
Operators Swift C#
arithmetic +, -, *, /, % +, -, *, /, %
assignment = =
bitwise <<, >>, &, |, ~, ^, <<, >>, <<=, >>= &, |, ^, ~
overflow &+, &-, &*, &/, &% checked unchecked
overloading overloading overloading
range a..<b, a…b (no equivalent)
relational ==, !=, >, < ==, !=, >, <
Programs Swift C#
attribute Non user definable attibutes User defined attributes
memory management automatic reference counting tree-based garbage collection
module module library
namespace (no equivalent) namespace
preprocessor directives compiler directives, diagnostic-directives preprocessor directives
Control flow Swift C#
break, continue break, continue break, continue
do-while repeat-while do-while
for for for
for-in for-in foreach-in
if if if
locking (no equivalent) lock
queries (no equivalent) LINQ
switch switch, fallthrough switch
try-catch, throw assert, try-catch, throw try-catch, throw
using (no equivalent) using
unsafe (no equivalent) unsafe
while while while
yield (no equivalent) yield
Classes Swift C#
constructor init constructor
class class class
partial class (no equivalent) partial class
delegate function types, lambdas (swift calls them closures) delegate, lambdas
destructor deinit destructor
extension extension (most types) extension (only class but swift like extension planned )
indexing subscript indexer
inheritance : :
access private, fileprivate, internal, public, open public, private, protected, interal
object AnyObject (reference), Any (value) object
self self this
type casting is, as, as? is, cast, dynamic, as
type alias typealias (supports Generics) using
Types Swift C#
enumerations enum enum
functions top level func (no equivalent) maybe delegates
protocol protocol interface
struct struct struct
Functions Swift C#
anonymous closures lambdas
class method static static
method func method
overloaded overloading overloading
override override override
ref parameter inout, & ref, &
parameter array params, T... parameter array
return return return
Collections Swift C#
dictionary Dictionary<Key, Value> Dictionary<S,T>
initialization object initializer object initializer
list Array List<T>
set Set HashSet<T>
Math Swift C#
minimum min Min
maximum max Max
power pow Pow
random numbers random Random.Next
trigonometry sin Sin
Generics Swift C#
function generic functions generic functions
type generic types generic types

swiftcsharp's People

Contributors

aloisdg avatar masters3d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

nickarthur

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.