问题描述
我是新手C#编码器 - 尝试翻译.NET VB
I'm a rookie C# coder - trying to translate from .NET VB
这适用于VB:
  ;  受保护的子grvAllContacts_SelectedIndexChanged(ByVal sender As Object,ByVal e As EventArgs)
Dim Index As Integer = grvAllContacts.SelectedIndex
_PersonID = grvAllContacts.DataKeys(Index).Value
Session.Item(" PersonID")= _PersonID
Response.Redirect(" ViewContact.aspx")
结束子
Protected Sub grvAllContacts_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim Index As Integer = grvAllContacts.SelectedIndex
_PersonID = grvAllContacts.DataKeys(Index).Value
Session.Item("PersonID") = _PersonID
Response.Redirect("ViewContact.aspx")
End Sub
这不是:
protected void grvAllContacts_SelectedIndexChanged(object sender,EventArgs e)
int Index = grvAllContacts.SelectedIndex;
_PersonID = grvAllContacts.DataKeys(Index).Value;
会话[" _PersonID"] = _PersonID;
Response.Redirect(" ViewContact.aspx");
结束子
protected void grvAllContacts_SelectedIndexChanged(object sender, EventArgs e)
int Index = grvAllContacts.SelectedIndex;
_PersonID = grvAllContacts.DataKeys(Index).Value;
Session["_PersonID"] = _PersonID;
Response.Redirect("ViewContact.aspx");
End Sub
我怀疑答案为什么会让我对C#和OO有一个重要的了解。 谢谢你的帮助。
I suspect that the answer to why will lead me a key understanding of C# and OO. Thanks for your help.
推荐答案
_PersonID = grvAllContacts.DataKeys[Index].Value;
如果您使用转换器,它将无法识别如何处理'DataKeys',除非您在转换中包含'grvAllContacts'的定义。
If you used a converter, it will not recognize how to treat 'DataKeys' unless you've included the definition of 'grvAllContacts' in the conversion.
这篇关于Datakeys非可调用成员不能像方法一样使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!