Home All Groups Group Topic Archive Search About

Parse, ToString, and "Null"

Author
21 Feb 2006 12:30 AM
Chris
I was thinking that these two methods should be inverses of each other,
but that doesn't appear to be consistently the case in MS code.  Also,
I kind of think that Parse should not be case sensitive; 1e10 == 1E10.
For example:

         try
         {
            on = OracleNumber.Parse("Null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString()); // System.FormatException
         }

         try
         {
            s16 = SqlInt16.Parse("Null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString()); // No exception; s16 =
SqlInt16.Null
         }


         try
         {
            s32 = SqlInt32.Parse("Null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString()); // No exception; s32 =
SqlInt16.Null
         }

         try
         {
            s16 = SqlInt16.Parse("null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString()); // {"Input string was not
in a correct format."}
         }

         try
         {
            s32 = SqlInt32.Parse("null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString()); // No exception; s32 =
SqlInt16.Null
         }


         try
         {
            sdt = SqlDateTime.Parse("Null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString());  // no exception
         }

         try
         {
            sdt = SqlDateTime.Parse("null");
         }
         catch (Exception e)
         {
            Console.WriteLine(e.ToString()); // {"String was not
recognized as a valid DateTime."}
         }

// Why DateTime in the message?  The type I'm parsing is an
SqlDateTime.

Anyone know if case-sensitivity is expected to change?
Same question for consistency between the OracleClient types (written
by MS) and the SqlClient types?

Anyone happen to know how the .Net provider written by Oracle behaves?

-Chris

Author
23 Feb 2006 9:10 AM
Rami Saad
Hello Chris,

regarding case sensitivity, here's MS article about it:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
ml/cpconcasesensitivity.asp

as for Oracle .Net provider:
http://www.oracle.com/technology/tech/windows/odpnet/ODP.NET-FOV.html
also follow the links here:
http://www.oracle.com/technology/tech/windows/odpnet/index.html

Hope this helps solve your problem.

Best regards,
Rami Saad
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
Author
23 Feb 2006 9:56 PM
Chris
Well, I appreciate the links, but I take x.Parse(string) to mean, "Take
this string and attempt to create an object of type x that would mean
the same as the content of the string."  This has nada to do with case
sensitivity of identifiers, which is the subject of the first link; a
variable foo is categorically different from a string "foo"; null as a
language element is categorically different from a string whose value
is "null".

So, thanks, but does anyone else have a take on this?

-Chris

Show quote
"Rami Saad" wrote:
> Hello Chris,
>
> regarding case sensitivity, here's MS article about it:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
> ml/cpconcasesensitivity.asp
>
> as for Oracle .Net provider:
> http://www.oracle.com/technology/tech/windows/odpnet/ODP.NET-FOV.html
> also follow the links here:
> http://www.oracle.com/technology/tech/windows/odpnet/index.html
>
> Hope this helps solve your problem.
>
> Best regards,
> Rami Saad
> MEA Developer Support Center
> ITworx on behalf of Microsoft EMEA GTSC

AddThis Social Bookmark Button