本文介绍了在将VB代码转换为C#时如何替换关键字REPLACE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你好 我在这里使用在线工具将我的VB代码翻译成C#,在翻译的C#代码中有一些错误。 以下是VB代码 如果 rs.Item( prev_test_scores)<> 然后 prev_scores.Text =替换(rs.Item( prev_test_scores),vbnewline, < br>) prev_scores_box.Text = rs.Item( prev_test_scores) 如果 rs.Item( prev_experience)<> 然后 prev_experience.Text =替换(rs.Item( prev_experience),vbnewline, < br>)& & nbsp; prev_experience_box.Text = rs.Item( prev_experience) 如果 rs.Item ( bio_notes)<> 然后 bio_info.Text =替换(rs.Item( bio_notes),vbnewline, < br>)& & nbsp; bio_info_box.Text = rs.Item( bio_notes) 下面是翻译的C#代码 if(rs.Item(prev_test_scores)!=) { prev_scores.Text = rs.Item(prev_test_scores)。替换(Environment.NewLine,< br > ); } prev_scores_box.Text = rs.Item(prev_test_scores); if(rs.Item(prev_experience)!=) { prev_experience.Text = rs.Item(prev_experience)。替换(Environment.NewLine,< br > )+& ; NBSP;; } prev_experience_box.Text = rs.Item(prev_experience); if(rs.Item(bio_notes)!=) { bio_info.Text = rs.Item(bio_notes)。替换(Environment.NewLine,< br > )+& ; NBSP;; } bio_info_box.Text = rs.Item(bio_notes); 错误是: prev_scores.Text = rs [prev_test_scores]。替换(Environment.NewLine,); 'object'不包含'替换'的定义 建议我修复此错误。 解决方案 HelloAm here translating my VB code to C# using online tool, have some error in translated C# code.Below is the VB codeIf rs.Item("prev_test_scores") <> "" Then prev_scores.Text = Replace(rs.Item("prev_test_scores"), vbnewline, "<br>") prev_scores_box.Text = rs.Item("prev_test_scores") If rs.Item("prev_experience") <> "" Then prev_experience.Text = Replace(rs.Item("prev_experience"), vbnewline, "<br>") & "&nbsp;" prev_experience_box.Text = rs.Item("prev_experience") If rs.Item("bio_notes") <> "" Then bio_info.Text = Replace(rs.Item("bio_notes"), vbnewline, "<br>") & "&nbsp;" bio_info_box.Text = rs.Item("bio_notes")Below is the translated C# codeif (rs.Item("prev_test_scores") != ""){ prev_scores.Text = rs.Item("prev_test_scores").Replace(Environment.NewLine, "<br>");} prev_scores_box.Text = rs.Item("prev_test_scores"); if (rs.Item("prev_experience") != "") { prev_experience.Text = rs.Item("prev_experience").Replace(Environment.NewLine, "<br>") + "&nbsp;"; } prev_experience_box.Text = rs.Item("prev_experience"); if (rs.Item("bio_notes") != "") { bio_info.Text = rs.Item("bio_notes").Replace(Environment.NewLine, "<br>") + "&nbsp;"; } bio_info_box.Text = rs.Item("bio_notes");error is: prev_scores.Text = rs["prev_test_scores"].Replace(Environment.NewLine, "");'object' does not contain a definition for 'Replace'Please suggest me to fix this error. 解决方案 这篇关于在将VB代码转换为C#时如何替换关键字REPLACE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 07:30