Csharp Language

C# is an object-oriented language from Microsoft with a syntax similar to that of Java (see Java Language). See Csharp Features for a few details. See the online language reference [1] or download a word document [2] version of the reference or view a quick introduction to the language [3].

Note: Please keep all discussion of the language and its features in Csharp Language Discussion.

Techopedia explains C# (C Sharp)

The term’s # character derives its name from the musical sharp key, which denotes a one semitone pitch increase. C# is pronounced "see sharp."

C# improved and updated many C and C++ features, including the following:

C# has a strict Boolean data variable type, such as bool, whereas C++ bool variable types may be returned as integers or pointers to avoid common programming errors. C# automatically manages inaccessible object memory using a garbage collector, which eliminates developer concerns and memory leaks. C# type is safer than C++ and has safe default conversions only (for example, integer widening), which are implemented during compile or runtime.

No implicit conversions between Booleans, enumeration members and integers (other than 0) may be converted to an enumerated type. User-defined conversions must be specified as explicit or implicit, versus the C++ default implicit conversion operators and copy constructors.


Preliminary drafts of the next edition of the Csharp Language standard (featuring generics [Parametric Polymorphism], anonymous delegates [Lambda Expressions with Lexical Closure], partial types [just a way of splitting the definition of a type over multiple files - not very interesting really, except for people involved in code generation], nullable types, and various other new features), as of July 2004, are available at:


Interesting C#-related Discussions:

For comparisons with other languages, see...

And, of course, Language Pissing Match.

Similarly, a strongly critical fake FAQ, essentially a CSharp bashing page (concentrating on bashing technical issues) from a Java fanatic: www.geocities.com (slow site). At first glance it looks like a regular FAQ, until one notices a pattern in the conclusion of each article. Most of the criticisms are reasonable, but the recommendation given in the answer to the second test is wrong: operator overloading is a Good Thing, as long as + means + and indexing means indexing (and << and >> mean << and >>). If it wasn't for that last bit the fact that each recommendation makes it more Java-y could be a coinkydink.


Csharp ECMA Plans

I just thought I'd write a quick clarification to some of these emails. Last week Fujitsu, HP, Intel and Microsoft presented a proposal to ECMA's TC39 for the standardization of C# and the Common Language Infrastructure (CLI). The CLI consists on a runtime, a set of framework classes, a unified type system and a set of bindings to allow compiler developers to produce compilers for the CLI.

TC39 adopted a resolution commissioning 2 task groups to work on producing the standards for C# and the CLI. The C# task group is being convened by Carol Thompson of HP and the CLI group by Sam Ruby from IBM. Member companies from TC39 that were interested in working on this technology included IBM, Netscape, Sun, SHARE and Pixo.

During the presentation I was asked about whether or not there were 2 or more implementations of the CLI. At Microsoft we have implemented 2 versions of the CLI. These are known as our .NET Frameworks and .NET Compact Frameworks. Further it was asked what platforms these were running on. Currently Microsoft has these frameworks running on all the Windows platforms (Win2K through WinCE) and 1 non-Windows platform. Unfortunately I'm not able to comment any further on the non-Windows platform.

Additionally I was asked about open-source implementations, specifically a reference implementation. The sponsors of this project are considering an open-source implementation but have not made any decisions yet. In terms of releasing a reference implementation, it is the intention of the sponsors to work towards a full specification and not reference the solution to ambiguities to a particular implementation. This is fundamentally different from what has been suggested previously by some other companies.

We are very excited by the approval of ECMA for standardizing this technology and look forward to progressing through to a final standard around the end of next year.

If you have any questions please feel free to email me directly.

Tony Goodhew C# Product Manager Microsoft Corp. tgoodhew@microsoft.com


Isn't Cee Sharp simply a way for Microsoft to offer a Java that's tightly bound to the Windows API? They tried to extend Java, and the trademark/copyright holder (Sun) squawked. So they changed around some stuff, gave it a new name, and -- voila -- Cee Sharp. Look, Billy learned from Windows 3.1 (in comparison to the Mac look and feel) that all he has to do is change the name, make some changes here and there, and throw a gaggle of lawyers at the problem. I actually think that the concept of a Java that is tightly bound to the underlying platform is really great, and I wish Sun would just let us avoid the Cee Sharp fiction.

That depends, isn't Java Language a way for Sun to offer a Cee Plus Plus that's tightly bound to their own VM and dumbed down to make programming easier? Listen, every time a new C language comes out someone is going to claim theft. The fact is Java is broken in the view of many, it went too far and removed too many useful C constructs. Java stole ideas from Objective Cee, which stole them from Smalltalk Language. Every language borrows ideas from every other language, that's how it works. There haven't been any new ideas in like 20 years, existing ideas are just being recycled in different combinations.

I fear I didn't explain myself clearly enough. Immediately prior to announcing the creation of Cee Sharp, Microsoft and Sun had been in a public and protracted trademark dispute, which arose because Microsoft was distributing a Microsoft-specific Java VM (with the Java Logo) that provided direct access to the Windows API. Sun objected, claiming that this approach locked the resulting programs into Microsoft platforms. This replayed the earlier similar conflict between Digitalk and Parc Place about using native GUI within Smalltalk (with Parc Place playing the role of Sun and Digitalk playing the role of Microsoft). The courts sided with Sun, and Microsoft responded by announcing Cee Sharp. I make no value judgement here, in fact I thought I said pretty clearly that I prefer a Java that uses the real native UI. We learned how to do it in Smalltalk, and I think Java benefits from this change. Thus, I'm fine with "Cee Sharp", I just think it would be cleaner and more accurate to either call it Java or Java++.

C# is much more palatable to C++ developers because it allows them to keep Enums and stack based structs while offering the niceities of garbage collection and a more solid OO feel. Everything, even the primitives are objects. If you look at Java code, you'll find developers hack up these missing features anyway, so why not include them in the language? Not to meantion, C# is a standardized language, Java still isn't, Microsoft seems to be behaving far better than Sun in this situation, I'd keep that in mind when trying to make accusations.

Who's making accusations? Meanwhile, are any Cee Sharp implementations available for the Macintosh, Unix, or Linux? From what vendors? And are there any open-source Cee Sharp implementations yet?

Yes, there are! Mono is the most complete I believe, for Linux. Also, Microsoft offers .NET for OSX and FreeBSD.

"C# is a standardized language, Java still isn't" - only if you accept the premise that Microsoft can write standards while Sun cannot. Quite an assumption there.


Micro Soft has actually implemented and released a shared source implementation of the CLI, codenamed Rotor (see Shared Source Cli). Also, there is ongoing work on an open source, Linux-based implementation of the CLI and a Csharp Compiler over at go-mono.com .

Furthermore, there is ongoing work on a free software GNU/Linux and Win32 implementation (which actually started 6 months before the mono project if I am not mistaken). For more details, see www.dotgnu.org .


See Nunit Framework, Dot Net Unit, and Cs Unit. United Binary has Harness It which looks interesting.''


A lot of discussion moved to Csharp Literature And Interviews

Forecoming features of this language can be seen as this address: msdn.microsoft.com


Links: www.geocities.com (slow site)

Open Source Community: csharp-source.net

windows.oreilly.com Deep Inside C# - An interview with Microsoft Chief Architect Anders Hejlsberg, the chief inventor of the C# Language.

www.oreillynet.com Top Ten Traps in C# for C++ Programmers: An article written by Jesse Liberty, the author of Programming C#. This interesting article points out the main difference between C# and C++ and what should be noted when programmers were switching from C++ to C#.


The .NET framework is horribly incomplete with things like Com interop and late binding (VB.NET is much better for this), and misses a whole slew of conversions. Conversions/casts are very weak too, you can't convert a string[] to a String Collection or a List. Features in one collection/list/array aren't present in the other. You cant even cast a string to an int without a library call. Strings are immutable, making you include instantiate a new class (stringbuilder). And the lack of string processing (which nearly every program needs heavily) makes it very verbose. A simple one-liner in VB or scheme takes 8 lines and a loop. It also holds the record for the ugliest and least useful switch command. You must use useless breaks and you can only switch on int/strings.

Not true. I switch on enums every day. However, I have become a bit anti-if, and look for strategy patterns to eliminate switch and if statements.



See original on c2.com