VB.NET How to add a return attribute?

I am converting C # code to VB.Net, and C code has this above function:

[return: System.Xml.Serialization.XmlElementAttribute("Name", IsNullable=true)]
+3
source share
3 answers

Given this C # code:

public [return:XmlElement("Name", IsNullable=true)] string Foo()
{
    return "";
}

will translate something like:

Public Function Foo() As <XmlElement("Name", IsNullable := True)> String
    Return ""
End Function
+4
source

In VB.Net, just put it before the type in the As clause

Public Function Example() As <XmlElementAttribute("Name", IsNullable:=true)> As SomeType
  ...
End FUnction
0
source
-1

Source: https://habr.com/ru/post/1719102/


All Articles