VB.net conversion to c# -


i converting section of code vb.net c# , stuck in section

if not isnothing(successnode)     dim _data xelement = (from xml in xdoc.descendants("data") select xml).firstordefault     dim _count integer = _data.@count     if _count > 0         _objectcollection = new queryobjectcollection(_data.@listtype)         each item xelement in _data.elements(_data.@listtype)             if not isnothing(item.<recordno>)                 _objectcollection.keys.add(item.<recordno>.value)                 _objectcollection.objects.add(item)             end if         next     end if end if 

not sure _data.@count , _data.@listtype. there equivalent fuunction ic c#?

can me convert section of code c#?

it's vb shorthand.

in vb:

_data.@count _data.@listtype 

in c#:

_data.attribute("count").value _data.attribute("listtype").value 

specifically, part of vb.net language feature of called "xml literals", , used in conjunction linq xml. (c# has linq, not have xml literals.)

the .@name notation in vb code, when used on xelement denotes want retrieve attribute xml element specified name. there vb syntax looks ...<name> retrieve element of specified name, map c# .element("name").value.

see overview of linq xml in visual basic, , xml literals overview.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -