Live data from Hacker News

C# Tutorials

msdn.microsoft.com

51–60 of 66 posts

Re: C# Tutorials

#51
post #5

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.

Seriously, VS is amazing so I see it as a point in favour more than against. If you worry about the fact that it can cost a lot of money, you can use the Express version that is free and once you get going if you are having some revenue it's a product worth buying.

Re: C# Tutorials

#52
DO 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 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

#53

Earlier 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);

Ah, I see ! That's pretty awesome. You know Mads Torgersen recently gave a talk on "The Future of C#" in NDC London, he actually mentioned that they're thinking of something like that, I highly recommend you check it out.

Re: C# Tutorials

#55
post #42

I'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…

On the GAC: Never use the GAC -- except for platform libraries (System.*, etc.).

Always deploy your dependency DLLs side-by-side with your code.

Re: C# Tutorials

#56
post #43

Earlier 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;

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.

Re: C# Tutorials

#57

Earlier 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?

Unity3D uses Mono(not .net) which runs on all of those platforms

Re: C# Tutorials

#58
post #10

Earlier 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

I know. But it's not even released yet, and it takes a lot of time for such massive changes to ripple through until you can expect them to be useful for the general public: Developers need to be trained, documentation, tools and libraries updated and hyper conservative tech leads persuaded or dethroned.

Re: C# Tutorials

#59

DO 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…

Here's the updated version of the C# Programming Guide for anyone interested:

http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx

Re: C# Tutorials

#60

Earlier 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.

Yes, I just want the sugar. Also, must not be any slower than the if-then solution of course. If the func calls aren't inlined/removed I don't think it would be good enough perf wise.
Post reply on HN