Which is more efficient Cstr(value) or value.ToString()

前端 未结 9 948
我在风中等你
我在风中等你 2021-01-11 14:56

I am wondering which is more efficient, using CStr() or object.toString(). The reason I ask this is because I though all that CStr() done was to invoke the .ToString() metho

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 15:53

    For readability sake, if I were in the need to write code in VB.NET (I am a C# programmer), I would avoid the VB specific keywords/functions as much as possible. By using .NET classes and methods only, your code will be more understandable by people used to develop in other .NET languages. Not to mention that these functions are there mainly for compatibility with VB6 and they look a bit out of place compared to the .NET way of doing things.

    Of course there may be reasonable exceptions, sometimes VB.NET really makes very easy to do certain tasks and it can be convenient to take advantage of this; but as a genereal rule I would not use any VB.NET specific function.

提交回复
热议问题