Category Archives: C#

.Net Implicit Casts

Casts A cast is a conversion of data from one type to another, for example from an integer to a float. Implicit Casts An implicit cast is a conversion from one type to another that is automatically assumed by the … Continue reading

Posted in C#, VB.Net | Leave a comment

C#: How to Clone a Generic List

Found on StackOverflow, this is a tidy example of an generic extension method that uses LINQ: static class Extensions { public static IList<T> Clone<T>( this IList<T> listToClone) where T: ICloneable     {     return listToClone.Select(item => (T)item.Clone()).ToList(); } … Continue reading

Posted in C# | Leave a comment

Exception Passing DBNull.Value to a Varbinary Using Parameters.AddWithValue

In .Net it seems reasonable to try to pass a NULL to a SQL Server stored procedure using the following syntax (C#): myCommand.Parameters.AddWithValue("@MyParameter", DBNull.Value); Unfortunately, if the sproc is expecting a parameter of type Varbinary(max), the following exception will be … Continue reading

Posted in C# | 1 Comment