[Mono-list] Example code does not compile
Detlev Offenbach
detlev@die-offenbachs.de
Sat, 27 Apr 2002 18:27:47 +0200
--------------Boundary-00=_B2J8JZWPSKK08FUH1LKN
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: 8bit
Hallo,
I am a C# newbie and have a problem. The attached example code (taken
from a german magazine) does not compile using mcs 0.11. I get the
following error.
(process:5050): ** ERROR **: file unicode.c: line 294 (iconv_get_length):
should not be reached
aborting...
/usr/local/bin/mcs: line 2: 5050 Trace/Breakpoint ausgelöst
/usr/local/bin/mono /usr/local/bin/mcs.exe $*
As far as I can remember, it compiled with a previous version of mcs
(don't know which one it was)
Regards
Detlev
--
Detlev Offenbach
detlev@die-offenbachs.de
--------------Boundary-00=_B2J8JZWPSKK08FUH1LKN
Content-Type: text/x-c++src;
charset="us-ascii";
name="kreisbeispiel.cs"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="kreisbeispiel.cs"
// Datei kreisbeispiel.cs
using System;
namespace CSharpBeispiel {
public abstract class GeomObjekt {
public GeomObjekt(double x, double y) {
x_ = x; y_ = y;
}
public abstract void Print();
public double X { get { return x_; } }
public double Y { get { return y_; } }
private double x_, y_; // Referenzkoordinaten
}
public class Kreis : GeomObjekt
{
///<exception>ArgumentOutOfRangeException</exception>
public Kreis(double x, double y, double r)
: base(x, y) {
Radius = r; // nimmt auch Bereichsprüfung vor
}
public override void Print() {
Console.WriteLine("Kreis: "
+ X + ", " + Y
+ ", " + Radius);
}
public void Dispose() {
Console.Write("Dispose() von ");
Print();
}
///<exception>ArgumentOutOfRangeException</exception>
public double Radius
{
get { return r_; }
set {
if ( value< 0.0 )
throw new ArgumentOutOfRangeException("r",
value, "negativer Radius");
r_ = value;
}
}
private double r_;
}
public class Test {
static void Main(string[] args) {
Kreis K = null;
try {
K = new Kreis(1.0, 2.0, 3.0); // Referenz-Typ
K.Radius = 9.0; // erlaubt
K.Print();
K.Radius = -10.0; // provoziert Exception
} catch(Exception e) {
Console.WriteLine(e);
} finally {
if(K != null)
K.Dispose();
}
}
}
}
--------------Boundary-00=_B2J8JZWPSKK08FUH1LKN--