public class DemoImplicitClass{ public string SomeData; public DemoImplicitClass(string somedata = null) { SomeData = somedata; } public static implicit operator DemoImplicitClass(string somedata) { return new DemoImplicitClass(somedata); }}// sample test in some method or EventHandler:DemoImplicitClass demo1 = "hello";Console.WriteLine(demo1.SomeData);我通过两个在线(免费)C# - > VB转换器运行此C#代码:Telerik的转换器[ ^ ]给出了此输出:I ran this C# code through two on-line (free) C#->VB converters: Telerik's converter [^] gave this output:Public Class DemoImplicitClass Public SomeData As String Public Sub New(Optional somedata__1 As String = Nothing) SomeData = somedata__1 End Sub Public Shared Widening Operator CType(somedata As String) As DemoImplicitClass Return New DemoImplicitClass(somedata) End OperatorEnd Class DeveloperFusion的转换器在这个输入上被阻塞,从未完成转换。 我不认真VB.Net,但这里似乎有很好的讨论VB中的扩展和缩小转换:[ ^ ]。DeveloperFusion's converter choked on this input and never finished the conversion.I don't grok VB.Net, but there is what appears to be a good discussion of Widening and Narrowing conversions in VB here: [^]. 这篇关于没有属性的VB.NET类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-11 17:35