Jeremy Hopkin [mailto:[EMAIL PROTECTED]] wrote:
> I hate to say it but, I feel it must be said: > > You can use the VB.NET libraries from with C# > ( although: String has been renamed StrDup ) > > MyVar = Microsoft.VisualBasic.StrDup(65, "-"); It's actually Microsoft.VisualBasic.Strings.StrDup, but why you would go to such great lengths to do this is beyond me. Especially when if you look at the IL for StrDup all it's doing is what you should be anyway: calling new String('-', 65). <codeSnippet language="CIL"> .method public hidebysig static string StrDup(int32 Number, char Character) cil managed { // Code size 33 (0x21) .maxstack 2 .locals init (string V_0) IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: bge.s IL_0019 IL_0004: ldstr "Argument_GEZero1" IL_0009: ldstr "Number" IL_000e: call string Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(string, string) IL_0013: newobj instance void [mscorlib]System.ArgumentException::.ctor(string) IL_0018: throw IL_0019: ldarg.1 IL_001a: ldarg.0 IL_001b: newobj instance void [mscorlib]System.String::.ctor(char, int32) IL_0020: ret } // end of method Strings::StrDup </codeSnippet> You're also paying the price of that additional error handling. This is common throughout all the compatibility APIs. Honestly, VB.NET people would be doing themselves a favor if they quickly learned to let go of the quick and dirty VB shortcut functions of old and found their BCL equivalents. Granted, some of the functions actually do provide useful services beyond the BCL, but that's the exception not the norm. Later, Drew .NET MVP You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.