dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] [bugs #11998] Problems with casting arrays, isinst, a


From: James Michael DuPont
Subject: [Pnet-developers] [bugs #11998] Problems with casting arrays, isinst, and the as operator
Date: Thu, 17 Feb 2005 08:13:28 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050110 Firefox/1.0 (Debian package 1.0+dfsg.1-2)

Follow-up Comment #2, bugs #11998 (project dotgnu-pnet):

The workaround is to cast the object directly without as.
the test file shows that this works, and the data is preserved.
using System;

public class Testing
{
        public static void Main()
        {

                String foo = "fooo";
                Console.WriteLine(foo == null );

                object z= foo as object;
                Console.WriteLine(z == null );

                Array x = new string[1];
                x[0]=foo;
                Console.WriteLine(x == null );

                Console.WriteLine("raw");
                Console.WriteLine(x);

                Console.WriteLine("as object");
                Console.WriteLine(x as object[]);

                Console.WriteLine("cast ");
                Console.WriteLine((object[])x);

                Console.WriteLine("cast2 ");
                object[] y = (object[])x; 
                Console.WriteLine(y == null );
                Console.WriteLine(y);
                Console.WriteLine(y[0]);

                Console.WriteLine("cast as ");
                object[] z2 = x as object[]; 
                Console.WriteLine(z2 == null );

        }
}



    _______________________________________________________

This item URL is:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=11998>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]