translate line code C# to VB.NET
hi everybody,
does there can me tha traslation of next code c# vb.net? i'm working in wpf application (vb.net).
using system.io;
using system.collections.generic;
using system.linq;
using system.text;
using system.xml.linq;
namespace listviewtest
{
public class mydata
{
/// <summary>
/// saves items mydata.xml file in bin folder.
/// </summary>
/// <param name="items"></param>
public void save(system.windows.data.collectionview items)
{
xdocument xdoc = new xdocument();
xelement xeroot = new xelement("data");
xelement xesubroot = new xelement("rows");
foreach (var item in items)
{
listviewdata lvc = (listviewdata)item;
xelement xrow = new xelement("row");
xrow.add(new xelement("col1", lvc.col1));
xrow.add(new xelement("col2", lvc.col2));
xesubroot.add(xrow);
}
xeroot.add(xesubroot);
xdoc.add(xeroot);
xdoc.save("mydata.xml");
}
/// <summary>
/// gets data mydata.xml rows.
/// </summary>
/// <returns></returns>
public ienumerable<object> getrows()
{
list<listviewdata> rows = new list<listviewdata>();
if (file.exists("mydata.xml"))
{
// create query
var rowsfromfile = c in xdocument.load(
"mydata.xml").elements(
"data").elements("rows").elements("row")
select c;
// execute query
foreach (var row in rowsfromfile)
{
rows.add(new listviewdata(row.element("col1").value,
row.element("col2").value));
}
}
return rows;
}
}
}
i have following (the 'telerik' conversion absolute garbage, way reed):
option infer on imports system imports system.io imports system.collections.generic imports system.linq imports system.text imports system.xml.linq namespace listviewtest public class mydata ''' <summary> ''' saves items mydata.xml file in bin folder. ''' </summary> ''' <param name="items"></param> public sub save(byval items system.windows.data.collectionview) dim xdoc new xdocument() dim xeroot new xelement("data") dim xesubroot new xelement("rows") each item in items dim lvc listviewdata = ctype(item, listviewdata) dim xrow new xelement("row") xrow.add(new xelement("col1", lvc.col1)) xrow.add(new xelement("col2", lvc.col2)) xesubroot.add(xrow) next item xeroot.add(xesubroot) xdoc.add(xeroot) xdoc.save("mydata.xml") end sub ''' <summary> ''' gets data mydata.xml rows. ''' </summary> ''' <returns></returns> public function getrows() ienumerable(of object) dim rows new list(of listviewdata)() if file.exists("mydata.xml") ' create query dim rowsfromfile = c in xdocument.load("mydata.xml").elements("data").elements("rows").elements("row") select c ' execute query each row in rowsfromfile rows.add(new listviewdata(row.element("col1").value, row.element("col2").value)) next row end if return rows end function end class end namespace
convert between vb, c#, c++, & java (http://www.tangiblesoftwaresolutions.com)
instant c# - vb c# converter
instant vb - c# vb converter
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment