[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[DotGNU]Force byte type for enumerator runtime error
From: |
Mike Peters |
Subject: |
[DotGNU]Force byte type for enumerator runtime error |
Date: |
Sun, 9 Mar 2003 15:05:19 +0200 |
Hi,
Firstly, is this the right place to post this type of thing? If not I
appologise.
The following code:
using System;
class enumDays
{
public enum Days: byte
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
public static void Main()
{
Array daysArray=Enum.GetValues(typeof(enumDays.Days));
foreach(Days day in daysArray)
{
Console.WriteLine("Number {1} of enumDays.Days is {0}",
day,
day.ToString("d"));
}
}
}
when run throws up:
Uncaught exception: System.FormatException: The supplied value did not
have the correct format
at
System.Private.NumberFormat.GeneralFormatter.PrecisionOf(Object) in
./System/Private/NumberFormat/GeneralFormatter.cs:59
at System.Private.NumberFormat.GeneralFormatter.Format(Object,
IFormatProvider) in ./System/Private/NumberFormat/GeneralFormatter.cs:86
at System.Byte.ToString(String, IFormatProvider) in
./System/Byte.cs:69
at System.Byte.ToString() in ./System/Byte.cs:56
at System.Enum.Format(Type, Object, String) in
./System/Enum.cs:134
at System.Enum.ToString(String, IFormatProvider) in
./System/Enum.cs:591
at System.Enum.ToString(String) in ./System/Enum.cs:577
at enumDays.Main()
Replacing byte with int runs as expected.
Thanks
--
Mike
Registered Linux User #247123
It was all very well going about pure logic and how the universe was
ruled by logic and the harmony of numbers, but the plain fact was that
the disc was manifestly traversing space on the back of a giant turtle
and the gods had a habit of going round to atheists' houses and smashing
their windows.
(Colour of Magic)
- [DotGNU]Force byte type for enumerator runtime error,
Mike Peters <=