The [User:Ed Ropple|RogueSDL]] library is designed to work with C#, via .NET and Mono, to provide developers with an easy-to-use, quickly implemented graphics and input system for a Roguelike. RogueSDL has been deprecated in favor of libtcod-net.

+

The [[User:Ed Ropple|RogueSDL]] library is designed to work with C#, via .NET and Mono, to provide developers with an easy-to-use, quickly implemented graphics and input system for a Roguelike. RogueSDL has been deprecated in favor of libtcod-net.

[http://code.google.com/p/libtcod-net/ libtcod-net] is a C# library that works under .NET and Mono, that provides bindings to [http://jice.nospam.googlepages.com/thedoryenlibrary TheDoryenLibrary]. This library provides a full console emulator, field of view, configuration file parsing, random number generation, and other things useful for a Roguelike. libtcod-net is, however, stalled in development, though fully functional with version 1.3 of The Doryen Library.

[http://code.google.com/p/libtcod-net/ libtcod-net] is a C# library that works under .NET and Mono, that provides bindings to [http://jice.nospam.googlepages.com/thedoryenlibrary TheDoryenLibrary]. This library provides a full console emulator, field of view, configuration file parsing, random number generation, and other things useful for a Roguelike. libtcod-net is, however, stalled in development, though fully functional with version 1.3 of The Doryen Library.

Revision as of 19:59, 9 October 2008

Contents

Background

C# is an object-orientedprogramming language developed by Microsoft as part of their .NET initiative. Microsoft based C# on C++ and Java. C# was designed as a language that would provide a balance of C++ with rapid development, Visual Basic, Delphi, and Java.

Language Characteristics

C# is, in some sense, the programming language which most directly reflects the underlying .NET Framework on which all .NET programs run, and it depends strongly on this framework; there is no such thing as an unmanaged C# program. Its primitive datatypes are objects of the corresponding .NET types, it is garbage-collected, and many of its abstractions, such as its classes, interfaces, delegates, exceptions, and so on, expose explicit features of the .NET runtime.

Compared to C and C++, the language is restricted or enhanced in a number of ways, including but not limited to the following:

C# is originally Windows platform (end user must have .NET framework installed). However, the C# language is an open ECMA standard and can be reimplemented by anyone who chooses to; the Mono Framework is a very full-featured system available for Windows, OS X and Linux, even able to run most .NET-compiled applications so long as these applications do not use Windows API calls directly.

The Managed DirectX classes were designed for use in C# and make using DX easy.

Raw pointers and unchecked arithmetic can only be used in a special unsafe mode. Most object access is done through safe references, which cannot be made invalid, and most arithmetic is checked for overflow.

Objects cannot be explicitly freed, but instead are garbage collected when no more references to them exist.

As in Java, only single inheritance is available, but a class can implement any number of abstract interfaces. This functions mainly to simplify the runtime's implementation.

C# is more typesafe than C++. The only implicit conversions by default are safe conversions, such as widening of integers and conversion from a derived type to a base type. There are no implicit conversions between booleans and integers, between enumeration members and integers, no void pointers (although references to Object are similar), and any user-defined implicit conversion must be explicitly marked as such, unlike C++'s copy constructors.

Syntax for array declaration is different ("int[] a = new int[5]" instead of "int a[5]").

C# has no templates, but C# 2.0 has generics, and these support some features not supported by C++ templates such as type constraints on generic parameters. On the other hand, expressions cannot be used as generic parameters as in C++ templates.

Full reflection is available.

Although C# is often considered similar to Java, there are also a number of notable differences with this language as well, including the following:

Java does not have operator overloading.

Java does not have an unsafe mode permitting native pointer manipulation and unchecked arithmetic.

Java has checked exceptions, while C# exceptions are unchecked, as in C++.

C# supports structures in addition to classes. Structures, known in the .NET Framework as value types, are comparable to C structures, in that they need not be heap-allocated and can limit the number of dereferences needed to access data; see value type.

C# has a unified object model for value-types and objects (There is no difference between "int" and "System.Int32").

Portability

C# is a ECMA and ISO standardized language. There are currently a number of C# implementations. More information can be found here.

C# Roguelikes

The site Evil Science contains a small section containing C# code samples for basic Roguelike concepts.

C# Roguelike Library

The RogueSDL library is designed to work with C#, via .NET and Mono, to provide developers with an easy-to-use, quickly implemented graphics and input system for a Roguelike. RogueSDL has been deprecated in favor of libtcod-net.

libtcod-net is a C# library that works under .NET and Mono, that provides bindings to TheDoryenLibrary. This library provides a full console emulator, field of view, configuration file parsing, random number generation, and other things useful for a Roguelike. libtcod-net is, however, stalled in development, though fully functional with version 1.3 of The Doryen Library.