Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will VB.NET and C# CIL look the same?

Tags:

c#

.net

cil

When I build my .NET application, what will the assembly contain? CIL? And second question, when doing the same thing in different .NET langugaes, will the CIL be exactly the same or same in the terms of similarity that works exactly the same way? Thanks

like image 340
Mocco Avatar asked Mar 14 '11 14:03

Mocco


3 Answers

No, they won't be the same.
VB.Net uses helper methods in Microsoft.VisualBasic.dll instead of many IL instructions to achieve VB semantics.
This includes equality ("" = Nothing), certain string operations, and I don't remember what else.

like image 172
SLaks Avatar answered Sep 28 '22 13:09

SLaks


You can not guarantee that VB.Net and C# will boil down to the same IL, but provided you wrote functionally identical routines, the IL could produce the same result.

like image 27
hometoast Avatar answered Sep 28 '22 12:09

hometoast


For many methods, the compiled result (CIL) will be the same.

There are however constructs in either language that are solved differently, or just not possible. This can never result in the same instructions.

like image 24
GvS Avatar answered Sep 28 '22 13:09

GvS