From a distance, C# looks like an incredibly awesome language, but the way it's tied so closely to Visual Studio and Windows really crimps its growth. I love it's syntax, the libraries look great, and apparently the performance isn't that bad either.
C# Tutorials
51–60 of 66 posts
Re: C# Tutorials
#52This is from Visual Studio 2003 and will be a terrible, terrible guide. Yes, that's 2003, over a decade ago.
C# programming has moved far away from the Java inspired boiler-plate of that time (as I assume Java has).
For example the properties tutorial is completely wrong as it doesn't include the new simple syntax which you should be using 95% of the time `public string Name { get; set; }`.
Also the way people use objects in C# has fundamentally shifted, in 2003 people didn't really get OO programming or when it was useful so almost everything was an object, frustratingly so at times.
And of course .net 3.5 & 4 have introduced massive programming paradigm shifts, transforming how you write C# completely, which aren't mentioned here, lambda expressions, async/await and extension methods.
(On top of that MS has never been very good at writing good example code anyway, generally use their code as documentation, not as inspiration. Their 'example' projects are often things to be laughed at, not imitated).
Re: C# Tutorials
#53Earlier quoted context omitted.
What exactly do you mean by "Tuple Construction/Deconstruction", honest question ? What's the problem with : var t = new Tuple (1, 2); I apologize if I misunderstood you.
Like in languages like python or most functional languages where you can deconstruct a returned tuple. Imagine a function that returns a point tuple. Instead of this: var p = SomeFunc(); print("X value is "+p.X); You would do this (x, y) = SomeFunc(); print("X value is "+x);
Re: C# Tutorials
#54Re: C# Tutorials
#55I'm still confused by the use of '.' to conflate namespaces & classes, and other things together. A separate character, like ':' or something else would've helped me :) Or GACs, or finding the right System.Data.SQLite module for your app - http://system.data.sqlite.org/index.html/doc/trunk/www/downl... Or figuring out how exactly deployments/setups work - where things get put, etc. I don't know much about java - but…
Always deploy your dependency DLLs side-by-side with your code.
Re: C# Tutorials
#56Earlier quoted context omitted.
Uhm http://en.wikipedia.org/wiki/Null_coalescing_operator First sample is C#?
Sorry, I meant a null coalescing property access operator that returns null if the left hand side is null. Today you write something like this var street = (user != null && user.Address != null) ? user.Address.Street : null; When you could use something like this var street = user?.Address?.Street;
public static TReturn Try(this TType value, Func accessor)
{
if (value == null) return default(TReturn);
return accessor(value);
}
The compiler should infer the generic types for you: var street = user.Try(_ => _.Address).Try(_ => _.Street);
Sure the syntactic sugar is nicer but the extension method's not that much worse.Re: C# Tutorials
#57Earlier quoted context omitted.
> C# is only really practical for Microsoft's platforms. Not necessarily. If you're doing game development with Unity3D, for example, you're probably going to write much of your game in C#, and it's going to run on Windows, Linux, OS X, Android and iOS.
How does Unity3D get C# to run on all those platforms?
Re: C# Tutorials
#58Earlier quoted context omitted.
C# is years ahead on the language feature side: - lambdas - Expression trees - sensible operator overloading - value type semantics (you can define your own types that behave like primitives) - reified generics instead of type erasure, which means that you can have an table (just two ints instead two pointers to Integer) - "async monad" baked into the syntax On the other hand, Java wins easily on the open source lib…
Java 8 supports lambdas
Re: C# Tutorials
#59DO NOT USE!! This is from Visual Studio 2003 and will be a terrible, terrible guide. Yes, that's 2003, over a decade ago. C# programming has moved far away from the Java inspired boiler-plate of that time (as I assume Java has). For example the properties tutorial is completely wrong as it doesn't include the new simple syntax which you should be using 95% of the time `public string Name { get; set; }`. Also the way…
Re: C# Tutorials
#60Earlier quoted context omitted.
Sorry, I meant a null coalescing property access operator that returns null if the left hand side is null. Today you write something like this var street = (user != null && user.Address != null) ? user.Address.Street : null; When you could use something like this var street = user?.Address?.Street;
Easily solved with an extension method; public static TReturn Try (this TType value, Func accessor) { if (value == null) return default(TReturn); return accessor(value); } The compiler should infer the generic types for you: var street = user.Try(_ => _.Address).Try(_ => _.Street); Sure the syntactic sugar is nicer but the extension method's not that much worse.