C# is an object-oriented language from Microsoft with a syntax similar to that of Java (see JavaLanguage). See CsharpFeatures 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 CsharpLanguageDiscussion.
[1] http://msdn.microsoft.com/library/prelim/csref/vcoriCReference.htm
[2] http://msdn.microsoft.com/vstudio/nextgen/technology/clangref.exe
[3] http://msdn.microsoft.com/vstudio/nextgen/technology/csharpintro.asp
[4] http://csharp.net-informations.com
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 CsharpLanguage standard (featuring generics [ParametricPolymorphism], anonymous delegates [LambdaExpressions with LexicalClosure], 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:
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 CeeSharp 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 -- CeeSharp. 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 CeeSharp fiction.
That depends, isn't JavaLanguage a way for Sun to offer a CeePlusPlus 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 ObjectiveCee, which stole them from SmalltalkLanguage. 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 CeeSharp, 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 ParcPlace about using native GUI within Smalltalk (with ParcPlace playing the role of Sun and Digitalk playing the role of Microsoft). The courts sided with Sun, and Microsoft responded by announcing CeeSharp. 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 "CeeSharp", 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 CeeSharp implementations available for the Macintosh, Unix, or Linux? From what vendors? And are there any open-source CeeSharp 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.
MicroSoft has actually implemented and released a shared source implementation of the CLI, codenamed Rotor (see SharedSourceCli). Also, there is ongoing work on an open source, Linux-based implementation of the CLI and a CsharpCompiler? over at http://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 http://www.dotgnu.org.
Is there a TestingFramework for CsharpLanguage?
See NunitFramework, DotNetUnit, and CsUnit. United Binary has HarnessIt which looks interesting.''
A lot of discussion moved to CsharpLiteratureAndInterviews
Forecoming features of this language can be seen as this address: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbconcprogramminglanguagefuturefeatures.asp
Links: http://www.geocities.com/csharplink/link.html (slow site)
Articles: http://www.csharp-station.com/
Open Source Community: http://csharp-source.net
http://windows.oreilly.com/news/hejlsberg_0800.html Deep Inside C# - An interview with Microsoft Chief Architect Anders Hejlsberg, the chief inventor of the C# Language.
http://www.oreillynet.com/pub/a/dotnet/2002/02/11/csharp_traps.html 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 StringCollection? or a List<string>. 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 also: CsharpFeatures, CsharpLanguageDiscussion, HistoryOfCsharp, PolyphonicCeeSharp, NextGenerationWindowsServices, FsharpLanguage, AnakrinoDecompiler
CategoryCeeSharp CategoryProgrammingLanguage CategoryMicrosoftTechnology CategoryDotNet