tags:

views:

449

answers:

5

I've got to write few words about C#, generally piece of cake? No!

I've searched through various internet resources and books and what i got is kind of headache. For example Garbage Collector some sources says that this is C# feature, other that CLR got this feature and C# along with all other .NET languages got it by default. Ofcourse, my vote on CLR but there are lot other things that bring confusion, like avoiding explicit code conversions. Maybe i've got bad books and resources... so maybe someone would suggest some place where in clear way is said about C#

Second thing are origins of C# syntax, again few choices and nothing clear, other language combo by each other author. C, c++, Java, that's ok but VB6 and Delphi, i have doubts. And again features origin from these languages is mixed up with c# but in fact it is not clear if it is C# or CLR feature

MTH

A: 

The CLR is a development platform, a runtime environment, supporting managed code written in one of the .NET languages, of which C# is one. Garbage collection is a CLR feature. As are Code Access Security and Just In Time compilation of your managed code.

flesh
+5  A: 

GC is provided by the CLR

C# is everything that the language spec states, and no more.

Some of the more-interesting things that are actually C# features:

  • iterator blocks [yield return]
  • anonymous methods / closures / lambdas [the syntax, not to be confused with expression trees]

But anything that relates to the code you type, but which isn't directly provided by either the CLR or the framework is a language feature. Other languages may implement them too, of course...

  • using [try/finally/Dispose]
  • lock [Monitor.Enter/try/finally/Monitor.Exit]
  • foreach [GetEnumerator()/while/[Dispose]]
  • extension method resolution
  • query syntax ["where pred" to .Where(x=>pred) etc]

(these are just a few examples of course; and again - other languages are at liberty to also provide these features!)

Marc Gravell
+3  A: 

The GC itself is a CLR feature, but the C# language assumes that it's running on a platform with garbage collection - without defining the exact semantics.

It's a tough thing to pin down precisely, but a rough rule of thumb is "if it's well defined in the language specification, it's a C# feature."

If you could give some more examples of features to categorise ("avoiding explicit code conversions" isn't a language feature, unless you want to give some more detail) it would help.

Jon Skeet
A: 

You may the C# Language specification. Here are the references:

  1. C# Specification (MSDN)
  2. Standard ECMA-334 C# Language Specification
bhadra
A: 

Second thing are origins of C# syntax, again few choices and nothing clear, other language combo by each other author. C, c++, Java, that's ok but VB6 and Delphi,

Things C# got from VB:

  • Properties
  • Events
  • For-Each loops
  • Modules, declared as "static class" in C#
  • Using default properties to make a class work like an array
  • Late binding (C# 4)
  • Integer overflow checks (C, C++, and Java cannot detect when you overflow an integer)
  • P/Invoke for calling C++ dlls

In a way Optional Parameters (C# 4), but really that's from COM.

Jonathan Allen
This comment needs to be edited for clarity.
Greg
I really don't think C# got its dynamic features from VB...
Martinho Fernandes