在类或命名空间中不存在?

编程入门 行业动态 更新时间:2024-10-28 12:17:19
本文介绍了在类或命名空间中不存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在if语句中声明了一个对象,surgeonRow: if(addNewSurgeonChkBx.Checked == true) { DataRow surgeonRow = dsAddAssessment.Tables [" Surgeon"] .NewRow(); surgeonRow [" sgnTitle"] = titleCboBx .SelectedValue; surgeonRow [" sgnFName"] = fNameTxtBx.Text; surgeonRow [" sgnLName"] = lNameTxtBx.Text; surgeonRow [" estNo"] =会话[" establishment"]。ToString(); dsAddAssessment.Tables [" Surgeon"]。Rows.Add(surgeonRow); } 但是当我尝试再次使用它时: if(addNewSurgeonChkBx.Checked == true) { assessmentRow.SetParentRow(surgeonRow); } surgeonRow突出显示并且构建错误名称''surgeonRow'' 在类或命名空间中不存在给出了。 有没有办法参考它?我无法移动 DataRow surgeonRow = dsAddAssessment.Tables [" Surgeon"] .NewRow(); 行出if声明克服了这个错误,因为它产生了更多的错误。 谢谢。

解决方案

surgeonRow在if中声明声明,因此是该声明的当地 。在if之外声明它阻挡在 的顶部你的方法或班级的顶级。 最好的问候 Johann Blake

我试过这个但是如果我这样做会造成更多问题。我可能需要 来代替克服这些代码。 谢谢

不,你做错了。你不要移动整行,只需要 声明,就像这样... DataRow外科医生现在; if(addNewSurgeonChkBx.Checked == true) { surgeonRow = dsAddAssessment.Tables [" Surgeo * n"] .NewRow(); surgeonRow [" sgnTitle"] = titleCboBx.SelectedValue; surgeonRow [" sgnFName"] = fNameTxtBx.Text; surgeonRow [" sgnLName"] = lNameTxtBx.Text; surgeonRow [" estNo"] =会话[" establishment"]。ToStr * ing(); dsAddAssessment.Tables [" Surgeo * n"]。行。添加(SurgeonRow); } 最好的问候 Johann Blake

Hi, I declare an object, surgeonRow within an if statement: if(addNewSurgeonChkBx.Checked == true) { DataRow surgeonRow = dsAddAssessment.Tables["Surgeon"].NewRow(); surgeonRow["sgnTitle"] = titleCboBx.SelectedValue; surgeonRow["sgnFName"] = fNameTxtBx.Text; surgeonRow["sgnLName"] = lNameTxtBx.Text; surgeonRow["estNo"] = Session["establishment"].ToString(); dsAddAssessment.Tables["Surgeon"].Rows.Add(surgeonRow); } however when i try to use it again like this: if(addNewSurgeonChkBx.Checked == true) { assessmentRow.SetParentRow(surgeonRow); } surgeonRow is highlighted and the build error "The name ''surgeonRow'' does not exist in the class or namespace" is given. is there a way to reference it? I cant move the DataRow surgeonRow = dsAddAssessment.Tables["Surgeon"].NewRow(); line out of the if statement to overcome this error, as it produces more errors. Thanks.

解决方案

surgeonRow is declared inside an "if" statement and therefore is local to that statement. Declare it outside of the "if" block at the top of your method or the top of your class. Best Regards Johann Blake

I have tried this but it creates many more problems if i do. i may have to play around the the code to overcome those instead. Thanks

No you''re doing it wrong. You don''t move the entire line, just the declaration, like this... DataRow surgeonRow; if(addNewSurgeonChkBx.Checked == true) { surgeonRow = dsAddAssessment.Tables["Surgeo*n"].NewRow(); surgeonRow["sgnTitle"] = titleCboBx.SelectedValue; surgeonRow["sgnFName"] = fNameTxtBx.Text; surgeonRow["sgnLName"] = lNameTxtBx.Text; surgeonRow["estNo"] = Session["establishment"].ToStr*ing(); dsAddAssessment.Tables["Surgeo*n"].Rows.Add(surgeonRow); } Best Regards Johann Blake

更多推荐

在类或命名空间中不存在?

本文发布于:2023-11-09 14:56:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572664.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   空间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!