[Mono-list] §RE: [Mono-list] Suggestion: warning "member variable notinitialized"

A Rafael D Teixeira rafaelteixeirabr@hotmail.com
Sun, 08 Jun 2003 11:56:04 -0300


>From: Jonathan Stowe <gellyfish@gellyfish.com>
>To: Arild Fines <arild.fines@broadpark.no>
> > > On Sat, 2003-06-07 at 07:03, Thong (Tum) Nguyen wrote:
> > >> Members are implicitly initialized to 0 or null so they do have a
> > >> meaning even if you don't explicitly initialize them...
> > >
> > > Umm... no.
> > >
> > > Some [ValueType] types don't even have an equivalent to 0 or null.
> > > e.g., System.DateTime, IIRC.
> >
> > 	class Class1
> > 	{
> >         void Method()
> >         {
> >             Console.WriteLine( t );
> >         }
> > 		/// <summary>
> > 		/// The main entry point for the application.
> > 		/// </summary>
> > 		[STAThread]
> > 		static void Main(string[] args)
> > 		{
> > 			new Class1().Method();
> > 		}
> >
> >         private DateTime t;
> > 	}
> >
> > Prints 01.01.0001 00:00:00.
> >
>
>But try comparing that to 0 or null ;-)
>
>/J\
>--
>Jonathan Stowe                      |

You have to compare it to DateTime.MinValue. You can't mix types in 
comparison, unless they have implicit conversion operators.

Happy hackings,

Rafael Teixeira
Brazilian Polymath
Mono, MonoQLE Hacker

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join.msn.com/?page=features/virus