[Mono-list] Some C# problems
Simon Waite
simon@psionics.demon.co.uk
Tue, 6 Aug 2002 01:01:55 +0100
I can confim that it's an issue under mono/mint and it's not a compiler
problem.
D:\project\mono>csc kentest.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
D:\project\mono>kentest
Welcome to Tic Tac Toe
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
D:\project\mono>
-------------------------------------------------------------------
under mono 0.13
demo@gemini:/tmp$ mcs kentest.cs
Compilation succeeded
demo@gemini:/tmp$ mono kentest.exe
Welcome to Tic Tac Toe
** (process:18901): WARNING **: unhandled exception
System.NullReferenceException: "A null value was found where an object
instance was required"
in (unmanaged) (managed to native wrapper) System.Array:GetLength (int)
in <0x00004> (managed to native wrapper) System.Array:GetLength (int)
in <0x00079> .Board:.ctor (int)
in <0x0005c> .TicTacToe:Main ()
and
demo@gemini:/tmp$ mint kentest.exe
Welcome to Tic Tac Toe
** (process:19194): WARNING **: unhandled exception
System.NullReferenceException: "Segmentation fault"
TODO: implement stack traces
-------------------------------------------------------------------
(after scping the VS exe to /tmp )
demo@gemini:/tmp$ mono kentest.exe
Welcome to Tic Tac Toe
** (process:19062): WARNING **: unhandled exception
System.NullReferenceException: "A null value was found where an object
instance was required"
in (unmanaged) (managed to native wrapper) System.Array:GetLength (int)
in <0x00004> (managed to native wrapper) System.Array:GetLength (int)
in <0x00097> .Board:.ctor (int)
in <0x0005c> .TicTacToe:Main ()
-------------------------------------------------------------------
(after scping the MCS exe to windows
D:\project\mono>kentest
Welcome to Tic Tac Toe
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
D:\project\mono>
-------------------------------------------------------------------
----- Original Message -----
From: "Kenneth Christiaansen" <kenneth@gnu.org>
To: <mono-list@ximian.com>
Sent: Monday, August 05, 2002 11:48 PM
Subject: [Mono-list] Some C# problems
> He everyone,
>
> I am having some problems with the attached code. This is the first I play
> with C# so it might include sillynesses. It compiles fine, but I get the
> following failures while running the code:
>
> ** (process:31789): WARNING **: unhandled exception
> System.NullReferenceException: "A null value was found where an object
> instance was required"
> in (unmanaged) (managed to native wrapper) System.Array:GetLength (int)
> in <0x00004> (managed to native wrapper) System.Array:GetLength (int)
> in <0x00079> .Board:.ctor (int)
> in <0x0005c> .TicTacToe:Main ()
>
> So if anyone can give me a hint on what I am doing wrong, or tell me this
is
> a bug, then please feel free doing so.
>
> Cheers, Kenneth
>
>
> using System;
>
> class TicTacToe {
>
> class Board {
> enum Block {
> Circle,
> Cross,
> None,
> };
>
> private Block [,] board;
>
> public Board (int size)
> {
> board = new Block [size, size];
>
> for (int i = 0; i < board.GetLength (0); i++) {
> for (int j = 0; j < board.GetLength (1); j++) {
> board [i, j] = Block.None;
> }
> }
> }
>
> public void DrawBoard ()
> {
> for (int i = 0; i < board.GetLength (0); i++) {
> for (int j = 0; j < board.GetLength (1); j++) {
> switch (board [i, j])
> {
> case Block.None:
> Console.Write (".");
> break;
> case Block.Cross:
> Console.Write ("X");
> break;
> case Block.Circle:
> Console.Write ("O");
> break;
> }
> }
> Console.WriteLine ("");
> }
> }
> }
>
> static public void Main ()
> {
> Console.WriteLine ("Welcome to Tic Tac Toe");
> Board board = new Board (10);
> board.DrawBoard ();
> }
> }
>
>
>
> _______________________________________________
> Mono-list maillist - Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list