Is replacing an optional parameter with overloads a breaking change?

I thought that was a good question, so here goes my take. Using a quick client that does this: c1.Foo(1); c1.Foo(1, 2); When using optional parameter the client IL looks like: IL_0000: nop IL_0001: newobj instance void [ClassLibrary1]ClassLibrary1.Class1::.ctor() IL_0006: stloc.0 IL_0007: ldloc.0 IL_0008: ldc.i4.1 IL_0009: ldc.i4.5 IL_000a: callvirt instance void [ClassLibrary1]ClassLibrary1.Class1::Foo(int32, int32) IL_000f: nop IL_0010: … Read more

How to use TransactionScope properly?

The code within the methods you call need to be transaction aware and enlist in the active transaction. This means creating or using classes which are resource managers (see Implement Your Own Resource Manager. You do this by implementing IEnlistmentNotification and enlisting in the transaction. When the transaction is completed, the transaction manager will call … Read more

VB.NET class inherits a base class and implements an interface issue (works in C#)

You need to mark your property as Overridable or MustOverride in the base class and then you can override it in the child class: Public MustInherit Class FooBase Private _Description As String Public Overridable Property Description() As String Get Return _Description End Get Set(ByVal value As String) _Description = value End Set End Property End … Read more

Inserting an IEnumerable collection with Dapper errors out with “class is not supported by Dapper.”

I just added a test for this: class Student { public string Name {get; set;} public int Age { get; set; } } public void TestExecuteMultipleCommandStrongType() { connection.Execute(“create table #t(Name nvarchar(max), Age int)”); int tally = connection.Execute(@”insert #t (Name,Age) values(@Name, @Age)”, new List<Student> { new Student{Age = 1, Name = “sam”}, new Student{Age = 2, … Read more

What are the most important functional differences between C# and VB.NET?

The linked comparisons are very thorough, but as far as the main differences I would note the following: C# has anonymous methodsVB has these now, too C# has the yield keyword (iterator blocks)VB11 added this VB supports implicit late binding (C# has explicit late binding now via the dynamic keyword) VB supports XML literals VB … Read more

Compress large Integers into smallest possible string

Yes. GZIP is a compression algorithm which both requires compressible data and has an overhead (framing and dictionaries, etc). An encoding algorithm should be used instead. The “simple” method is to use base-64 encoding. That is, convert the number (which is represented as base 10 in the string) to the actual series of bytes that … Read more

Force break on any exception thrown in program

VS2015 and later: Go into Debug > Windows > Exception Settings and check the tick box against Common Language Runtime Exceptions (below the ‘Break When Thrown’ column header). VS2013 and earlier: Go into Debug > Exceptions and check the Thrown box against Common Language Runtime Exceptions. You may get a lot of noise this way … Read more