Live data from Hacker News

C# Tutorials

msdn.microsoft.com

41–50 of 66 posts

Re: C# Tutorials

#41
post #12

Unsafe code( pointers ), shows and example of a copy, where a byte* is casted to a int* and then dereferenced. Such operation in c produces undefined behavior( even if byte points to data large enough ). Safe or not, does c# consider such dereference as defined behavior?

There is no concept of "dereferencing" in C# because there are no pointers. Technically it is possible to force the environment to allow you to write unsafe code but I've never seen this in reality and I'm having a hard imagining where it would be useful.

One thing where it is useful is manipulating image data. You can get a raw pointer from the Bitmap class you can then manipulate with unsafe code which is orders of magnitude faster than the normal variant. Basically you're saying, for a single method or a block of code "Please turn off all safety nets, but only for these 20 lines". The places where it's useful or necessary are quite few, though.

Re: C# Tutorials

#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 it seems easier there - here is the .jar, simple .zip file, look at the manifest - and you are done.

Re: C# Tutorials

#43

Top things I miss in C# - Null coalescing operator - Tuple Construction/Deconstruction - Algebraic data types/Pattern matching - List comprehensions/array slicing - Operators in interfaces After 10 years of C# I really feel that F# is the future.

Uhm http://en.wikipedia.org/wiki/Null_coalescing_operator

First sample is C#?

Re: C# Tutorials

#44
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…

The way I heard it put some time ago was, Java/JVM couldn't make some important changes because it would break backwards compatibility in an unacceptable way (I'm assuming this means there are mission critical apps written in Java 1 that the whole world depends on), but since C#/.NET were from scratch, they were free from this legacy baggage and could take huge steps forward.

Actually, .NET was in pretty much the same place, because generics were only implemented in .NET 2. They chose to add the support directly to the VM, though and break compatibility.

That being said, Java broke other things along the way back then, if I remember correctly, so in hindsight type erasure for fake generics was maybe not the smartest choice.

Re: C# Tutorials

#45

Top things I miss in C# - Null coalescing operator - Tuple Construction/Deconstruction - Algebraic data types/Pattern matching - List comprehensions/array slicing - Operators in interfaces After 10 years of C# I really feel that F# is the future.

[deleted]

Re: C# Tutorials

#46
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…

For package management I recommend you use NuGet and you should be good. No need to visit an sqlite website to download anything. Just type

   Install-Package System.Data.SQLite
In your VS package manager console and you are good to go.

Deployment/Setup is not really something C# or .NET cares about, there are many different forms of deployment. (IIS, Windows desktop, ClickOnce, Azure) and in each case you can do it in several different ways. I agree it's tricky to know what goes where sometimes, but it's more a problem with those targets than with how you build the application in question.

Re: C# Tutorials

#47
post #39

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.

Wish it was true. It has never been true and it is unlikely to be true in near future. Try some non toy F# on windows and on Mono and you will know. Mono leaks, and if you rely on correct behavior of tail calls, you are in for a lot of grief.

> Wish it was true.

It is true. You appear to be talking about something else.

Re: C# Tutorials

#48

Top things I miss in C# - Null coalescing operator - Tuple Construction/Deconstruction - Algebraic data types/Pattern matching - List comprehensions/array slicing - Operators in interfaces After 10 years of C# I really feel that F# is the future.

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.

Re: C# Tutorials

#49
post #43

Top things I miss in C# - Null coalescing operator - Tuple Construction/Deconstruction - Algebraic data types/Pattern matching - List comprehensions/array slicing - Operators in interfaces After 10 years of C# I really feel that F# is the future.

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;

Re: C# Tutorials

#50

Top things I miss in C# - Null coalescing operator - Tuple Construction/Deconstruction - Algebraic data types/Pattern matching - List comprehensions/array slicing - Operators in interfaces After 10 years of C# I really feel that F# is the future.

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);
Post reply on HN