代码解释,C#到VB.NET [英] Code Interpretation, C# to VB.NET

查看:57
本文介绍了代码解释,C#到VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

那里有人可以帮我解决下一个代码C#到VB.NET的问题吗?我正在使用WPF应用程序(VB.NET)。

注意:我的部件有问题:'//创建查询



 var rowsFromFile =来自XDocument.Load中的c(
MyData.xml)。Elements lang =sql>& quot; Data& quot;)。Elements( & quot; Rows& quot;)。元素(& quot;& quot;)
select c;







我找不到翻译。



使用System; 
使用System.IO;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Xml.Linq;

名称空间ListViewTest
{
公共类MyData
{
/// < 摘要 >
///将项目保存到bin文件夹中的MyData.xml文件。
/// < / summary > ;
/// < param name = items > < / param >
public void保存(System.Windows.Data.CollectionView项目)
{
XDocument xdoc = new XDocument( );

XElement xeRoot = new XElement(Data);
XElement xeSubRoot = new XElement(Rows);

foreach(项目中的var项目)
{
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);
}

/// < 摘要 >
///从MyData.xml获取数据作为行。
/// < / summary > ;
/// < 返回 > < / returns >
public IEnumerable < object > GetRows()
{
List < ListViewData > rows = new List < ListViewData > ();

if(File.Exists(MyData.xml))
{
//在XDocument.Load中创建查询
var rowsFromFile = c(
MyData.xml)。元素(
数据)。元素(行)。元素(行)
选择c;

//执行查询
foreach(rowsFromFile中的var row)
{
rows.Add(new ListViewData(row.Element(col1)。Value ,
row.Element(col2)。Value));
}
}
返回行;
}
}
}





谢谢

解决方案

而是要求别人为你做你的工作(如何理解你的要求),你应该自动学习如何做这些翻译。







祝你好运,

-SA

Hi everybody,
Does anybody there can help me with tha traslation of the next code C# to VB.NET? I'm working in WPF Application (VB.NET).
NOTE: I have a problem with the part: ' // Create the query

var rowsFromFile = from c in XDocument.Load(
                           "MyData.xml").Elements lang="sql">&quot;Data&quot;).Elements(&quot;Rows&quot;).Elements(&quot;Row&quot;)
                                  select c;




I can't found the traslation.

using System;
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 to 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 from MyData.xml as rows.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<object> GetRows()
        {
            List<ListViewData> rows = new List<ListViewData>();

            if (File.Exists("MyData.xml"))
            {
                // Create the query
                var rowsFromFile = from c in XDocument.Load(
                            "MyData.xml").Elements(
                            "Data").Elements("Rows").Elements("Row")
                                   select c;

                // Execute the query
                foreach (var row in rowsFromFile)
                {
                    rows.Add(new ListViewData(row.Element("col1").Value,
                            row.Element("col2").Value));
                }
            }
            return rows;
        }
    }
}



Thanks

解决方案

Instead asking others to do your job for you (how else can one understand your request), you should learn the ways to do such translations automatically.



Good luck,
—SA


这篇关于代码解释,C#到VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆