C#Web应用程序问题 [英] C # Web application Problem

查看:116
本文介绍了C#Web应用程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将任何文本框的字符串ie = 1,2,45,178移动到此格式的列表框中1 2 45 178逐项输出......在C#Web应用程序中



请建议一些相同的编码

I want to move string of any textbox ie = 1,2,45,178 to listbox in this format 1 2 45 178 itemwise output......in C# Web application

Please suggest some coding for the same

推荐答案

编译错误消息:CS0103:当前上下文中不存在名称'words'


来源错误:





第111行:

第112行:string [] splitedStr = text.Split(delimeterchars);

第113行:foreach(字符串str in words)

第114行:{

第115行:ListBox5.Items.Add(str.ToString(),str.ToString());





第113行中的错误请更正它........
Compiler Error Message: CS0103: The name 'words' does not exist in the current context

Source Error:


Line 111:
Line 112: string[] splitedStr = text.Split(delimeterchars);
Line 113: foreach (string str in words)
Line 114: {
Line 115: ListBox5.Items.Add(str.ToString(), str.ToString());


Error in Line 113 please correct it........


您可以使用 String.Split()方法。





例如:



You can use String.Split() method.


For example:

// your case delimiter will be ','

     char[] delimiterChars = { ',' };

      string text = txtbox1.Text;// txtbox1 is treated your textbox

      string[] splitedStr = text.Split(delimiterChars);

      foreach (string str in splitedStr )
      {
          lstbox1.Items.Add(str.ToString(),str.ToString());  //lstbox1 as your listbox
      }


你不能使用textbox.text.split(',')吗?
Can't you use textbox.text.split(',') ?


这篇关于C#Web应用程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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