C# : .NET's Native Tongue
Programmers familiar with C/C++ or Java may feel a sense of dejà vú when first coming into contact with the C# (pronounced C Sharp
) language, which, considering C# has its roots in the C++ language, should not be surprising. C# is developed by Microsoft to implement its .NET framework.
Advantages?
C# is a highly-managed language. What this means that the compiler
will not allow unsafe operations, unless explicitly forced to do so. This is intended to prevent the unintentional errors in logic and syntax other languages allow inexperienced programmers to code.
One of the unsafe operations
C# forbids is implicit conversion between incompatible data types. For instance, you cannot implicitly convert a Double object into a Single or Integer object. Why? Because your data becomes truncated. Single and Integer types are narrower
, meaning they have a smaller memory value, than Double types. Comparing a Single value to a Double value could cause improper execution of code that tests the equivalency of two or more objects, since the two values are not the same. For instance, to your computer 1.0000 is not the same as 1.00000000000000000000, even though the average person might think it is.
Cool! Hey, why did you quote compiler
? Something I should know?
That's for one simple reason. C#, like most modern OOP languages, does not actually compile. Rather, it is interpreted
into CIL byte-code when you ask your development environment to build the project code. Then, at runtime, a JIT (Just-In-Time) compiler completes the compilation into machine code. The advantage of using a JIT compiler versus a true
compiler is that the executable can be easily ported from system to system, as long as the proper runtime environment is present. For Microsoft languages, the necessary runtime is the .NET Framework.
Drawbacks?
While bytecode does make our code more portable (anything that can run a newer version of Windows can probably run our code), it also means our application takes longer to execute. Of course, the average user will never notice, as this only becomes an issue with systems that require high-speed processing, such as precision mold software or industrial color spectrum analyzers...
C# Keywords
There are certain words that have special meaning to the C# compiler and cannot be used in your code for anything else unless you precede them with the '@' sign.
The following list is every keyword as of .NET Framework 3.5.
| abstract | event | new | struct |
| as | explicit | null | switch |
| base | extern | object | this |
| bool | false | operator | throw |
| break | finally | out | true |
| byte | fixed | override | try |
| case | float | params | typeof |
| catch | for | private | uint |
| char | foreach | protected | ulong |
| checked | goto | public | unchecked |
| class | if | readonly | unsafe |
| const | implicit | ref | ushort |
| continue | in | return | using |
| decimal | int | sbyte | virtual |
| default | interface | sealed | volatile |
| delegate | internal | short | void |
| do | is | sizeof | while |
| double | lock | stackalloc | else |
| long | static | enum | namespace |
| string |
Source: MSDN Visual C# Developer Center

Subscribe
Categories
Navigate
Random Quote
There are no comments for this entry.