What features are heavily used in C # 2.0 but not available in VBNET 2.0, and how do I get around?

I don't want a war between VB.NET and C # developers, and my goal is to open the C # VS VB.NET confrontation.

I would like you all to point out a feature that is heavily used in C # but not available in VB.NET 2.0, and how would you work to achieve similar behavior or goal?

For instance:

FROM#

Accepts void (return) lambda expressions. Here's an example with FNH mapping:

Component(x => x.Address, m => { 
    m.Map(x => x.Number); 
    m.Map(x => x.Street); 
    m.Map(x => x.PostCode); 
});

      

This cannot be done before VB.NET 4.0 (assuming it is executable in VB.NET 4.0)

VB.NET

Should write a help method (Sub) and provide AddressOf this method to work around.

Private Sub Helper(ByVal m As MType) 
    m.Map(Function(x) x.Number) 
    m.Map(Function(x) x.Street) 
    m.Map(Function(x) x.PostCode) 
End Sub 

...   
Component(Function(x) x.Address, AddressOf Helper) 

      

Now I know this is not VB.NET 2.0, but this is an example. VB.NET 3.0 and 3.5 can be used too. Please just indicate which VB.NET version this applies to.

+2


a source to share


4 answers


You can check the wiki for comparison. See "Visual Basic.NET Features Not Found in C #" and "C # Features Not Found in Visual Basic.NET".



+4


a source


Iterator blocks (return / yield) are probably the largest.



+7


a source


For me, something I missed is the implicit interface definitions:

ISomething
{
   void Execute();
}

class ASomething : ISomething
{
   public void Execute()
  {
    //Do something
  }
}

      

Perfectly. In VB.net, you have to explicitly mark a method as an implementation of an interface, which I find quite annoying. I know there are people who prefer this technique, but not for me ...

+1


a source


An unsafe block of code using a keyword is unsafe

not allowed in VB.NET. There is no workaround. But to be honest, I have never used this feature. If I come across a situation that usually requires this feature, I usually kick and navigate right into C ++ / CLI.

+1


a source







All Articles