如何把VB语言转换为C#,求指导
<%@ImportNamespace="System"%><%@ImportNamespace="System.Xml"%><scriptlanguage="VB"run...
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object,e As EventArgs)
Dim content As New XmlDocument()
Dim objnode As XmlNode
Dim title,abstract,author,paragraph As String
content.Load(Server.MapPath(Request("name") +".xml"))
objnode=content.SelectSingleNode("document")
Response.Write("<h1 align=center>")
title=objnode.childnodes(0).Innertext
Response.Write(title)
Response.Write("</H1>")
Response.Write("<hr>")
Response.Write("<H2 align=center>")
abstract=objnode.childnodes(1).Innertext
Response.Write(" " & abstract)
Response.Write("</H2>")
Response.Write("<p Align='center'>")
author=objnode.childnodes(2).Innertext
Response.Write("作者: " &author)
Response.Write("</p>")
Dim i As Integer
For i=0 to objnode.childnodes(3).Childnodes.count-1
Response.Write("<p>")
paragraph=objnode.childnodes(3).Childnodes(i).innertext
Response.Write(paragraph)
Response.Write("</p>")
Next
End Sub
</script>
<html>
<head>
<title>
显示新闻内容
</title>
</head>
<body>
怎么把代码里的VB语言转换为C#? 展开
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object,e As EventArgs)
Dim content As New XmlDocument()
Dim objnode As XmlNode
Dim title,abstract,author,paragraph As String
content.Load(Server.MapPath(Request("name") +".xml"))
objnode=content.SelectSingleNode("document")
Response.Write("<h1 align=center>")
title=objnode.childnodes(0).Innertext
Response.Write(title)
Response.Write("</H1>")
Response.Write("<hr>")
Response.Write("<H2 align=center>")
abstract=objnode.childnodes(1).Innertext
Response.Write(" " & abstract)
Response.Write("</H2>")
Response.Write("<p Align='center'>")
author=objnode.childnodes(2).Innertext
Response.Write("作者: " &author)
Response.Write("</p>")
Dim i As Integer
For i=0 to objnode.childnodes(3).Childnodes.count-1
Response.Write("<p>")
paragraph=objnode.childnodes(3).Childnodes(i).innertext
Response.Write(paragraph)
Response.Write("</p>")
Next
End Sub
</script>
<html>
<head>
<title>
显示新闻内容
</title>
</head>
<body>
怎么把代码里的VB语言转换为C#? 展开
展开全部
public void Page_Load(object Sender, EventArgs e)
{
XmlDocument content = new XmlDocument();
XmlNode objnode = default(XmlNode);
string title = null;
string @abstract = null;
string author = null;
string paragraph = null;
content.Load(Server.MapPath(Request("name") + ".xml"));
objnode = content.SelectSingleNode("document");
Response.Write("<h1 align=center>");
title = objnode.childnodes(0).Innertext;
Response.Write(title);
Response.Write("</H1>");
Response.Write("<hr>");
Response.Write("<H2 align=center>");
@abstract = objnode.childnodes(1).Innertext;
Response.Write(" " + @abstract);
Response.Write("</H2>");
Response.Write("<p Align='center'>");
author = objnode.childnodes(2).Innertext;
Response.Write("作者: " + author);
Response.Write("</p>");
int i = 0;
for (i = 0; i <= objnode.childnodes(3).Childnodes.count - 1; i++) {
Response.Write("<p>");
paragraph = objnode.childnodes(3).Childnodes(i).innertext;
Response.Write(paragraph);
Response.Write("</p>");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询