|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Differences with Csharp
This page notes some differences between C# and boo. C# to Boo ConverterThe easiest way to see how code in boo differs from C# is to use the C# to boo converter included in the Boo AddIn For SharpDevelop. The converter is also accessible online via a webform here: http://developer.sharpdevelop.net/codeconvert.net/ While viewing a C# file in SharpDevelop, you can select from the menu: Tools -> Convert C# to boo. Or you can convert an entire C# project at once by right-clicking on the project icon and selecting: Convert -> C# to boo. Note, however, the converter is still new and in development. The converter will convert C# to legal boo code, but it will not show you the simplest way to write that code. For example, instead of "System.Console.WriteLine C# vs. Boo Syntax ExamplesHere is a table noting some diffences between C# and boo, based on this table from the Nemerle programming language site. See also the C# language specification. Expressions
Type definitions
Miscellaneous Differences and Similarities
Other Notes on Differences Between C# and BooThese are some early notes from looking at the C# language specification. Assigning multiple variables at onceIn C#, you can assign a value to two variables at once like so: In boo, however, "a, b" refers to a sequence. So you would instead use: Note also declaring the type is unnecessary because of boo's Type Inference. Use "a, b" when unpacking multiple values. For example: Also note in boo you can use the "print" statement instead of System.Console.WriteLine. Buffer overflow checkingYou can turn off overflow checking in boo like so: Variable number of parameters.Boo uses syntax similar to python: By reference and output parameters.In C# you can pass types to functions by reference using "ref" or "out" keywords. Boo supports the "ref" keyword, too, but not "out", which is unnecessary in boo. Note though that in this particular sample, you can swap two values more easily like so: As a more general alternative to by reference parameters, in boo you can also return multiple values from a function instead: Things in C# but not Boodo..while loopBoo doesn't have do..while or do..until loops like C# or VB.NET. You can emulate them with "while true" loops. unsafe code |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||