0

I am trying to gradually migrate my VB Dot Net code to use only CLS compliant language elements so that the eventual switch to C# is less painful.

Currently, I am using Microsoft.VisualBasic.vbTab and am looking for the CLS equivalent.

Thanks.

Keith Howard
  • 347
  • 4
  • 12
  • 1
    String literal formatting is not part of CLS, it is a language detail. Microsoft.VisualBasic.vbTab works in any language. – Hans Passant Mar 16 '19 at 15:29
  • 1
    You may misunderstand what "CLS compliant" means. All it means is that assemblies should respect certain rules to ensure they can be used from all languages. It is a property of an assembly, not a single constant -- and `Microsoft.VisualBasic` is CLS compliant, and can thus be used from any .NET language. You may choose to use `"\t"` to make the code more idiomatically C#, but there is nothing intrinsically limiting about using `Constants.vbTab` directly. In fact, since C# mandates that constants are inlined, code using it would compile indistinguishably from code using `\t`. – Jeroen Mostert Mar 16 '19 at 15:45
  • In fact, unless there is actual business value in "translating" the code to C# (because you have fewer people able or willing to maintain VB.NET code, for example) you could package your whole code lock, stock and barrel into assemblies, mark them as CLS compliant and continue to use them from C# code -- this would work perfectly fine. Of course, if the code will need to continue to be maintained it's less attractive to have multiple projects in different languages. – Jeroen Mostert Mar 16 '19 at 15:52
  • Correction (not going to delete and repost everything...) "CLS compliant" in fact applies to everything, from assemblies down to members. On the assembly level it just signals the default (so anything that's not CLS compliant must be explicitly marked as such). – Jeroen Mostert Mar 16 '19 at 15:59

0 Answers0