PROCEDURES AND FUNCTIONS IN .NET LANGUAGES SqlString s2

PROCEDURES AND FUNCTIONS IN .NET LANGUAGES SqlString s2 = {90110409-6000-11D3-8CFE-0150048383C9} ; SqlGuid g = (SqlGuid)s2; // this line prints out 90110409-6000-11D3-8CFE-0150048383C9 Console.WriteLine(g); In addition to explicit coercions, implicit ones are supported. An implicit coercion means the type will automatically be coerced when required. For example, a method that is defined as returning a SqlInt64can return a SqlInt32, because there is an implicit coercion from SqlInt32to SqlInt64. An example of this follows. public class Math { public static SqlInt64 Same3(SqlInt32 i) { // i is implicitly cast to SqlInt64 // because that is what is required // for the return value return i; } } Another example of implicit coercions follows. SqlDecimal sdecimal = new SqlDecimal(1.0); SqlDouble sdouble = 1.0; // the following line does an explicit conversion sdecimal = (SqlDecimal)sdouble; // the following line does an implicit conversion // not that it does not require (SqlDecimal) Sdecimal = sdouble; // the following attempts an implicit conversion but will // not work because there is no implicit conversion // from SqlDouble to SqlDecimal sdecimal = sdouble; // compile-time error In addition, a CLR type that corresponds to a SqlTypecan be implicitly coerced to that SqlType. The CLR type that corresponds to a SqlType is the type of the Value property of the SqlType. For example, the CLR type of the Valueproperty of SqlDoubleis System.Double. This means that no explicit conversion is required to set the value of a SqlDouble with a CLR double. The example that follows shows this. SqlDouble sdouble = new SqlDouble(1.0); // no explicit conversion is required because 3.0 // is a double and the type of the Value property // of SqlDouble is double sdouble = 3.0;

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Bookmark the permalink.

Comments are closed.