Nullable Types in VB.NET?
VB.Net does have nullable types, they can be declared in the following two different ways. Dim iNullable As Integer? or Dim iNullable As Nullable(Of Integer)
VB.Net does have nullable types, they can be declared in the following two different ways. Dim iNullable As Integer? or Dim iNullable As Nullable(Of Integer)
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
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
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
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
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
First, make sure you are profiling the performance properly. For example, run the query twice from ADO.NET and see if the second time is much faster than the first time. This removes the overhead of waiting for the app to compile and the debugging infrastructure to ramp up. Next, check the default settings in ADO.NET … Read more
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
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
The syntax of VB.NET in such a case is a little different. The equivalent of string[] dest; // more code here dest = new string[src.Length]; is Dim dest As String() ‘ more code here dest = New String(src.Length – 1) {} Syntax note When you use Visual Basic syntax to define the size of an … Read more