无法将类型string[]隐式转换为“System.Collectiotrojan.genericc.list<string[]>”

扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
没法将类型“string”隐式换为“System.Web.UI.WebControls.TextBox”
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口  在C#代码中使用一系列字符串(strings)并需要为其创建一个列表时,List&string&泛型类是一个用于存储一系列字符串(strings)的极其优秀的解决办法。下面一起有一些List&string&泛型类的示例,一起来看看吧。
  List示例
  下面是一个使用C#创建一个新的一系列字符串的列表的示例,利用foreach语句循环使用其每一个字符串。请注意在代码片段的顶部添加所需的命名空间:&using System.Collections.G&,List是该命名空间里的一个泛型类型。
List&string&示例代码:
1 using S 2 using System.Collections.G 3
4 class Program 5 { 6
static void Main() 7
List&string& cities = new List&string&(); // List of city names 9
cities.Add("San Diego");
// String element 110
cities.Add("Humboldt");
cities.Add("Los Angeles");
cities.Add("Auburn");
// Write each city string.15
foreach (string city in cities)16
Console.WriteLine(city);18
Console.ReadKey();20
San DiegoHumboldtLos AngelesAuburn
  注意代码中的尖括号(angle brackets)。在声明语句中尖括号&和&将string类型围在中间,这意味着List仅能够存储String类型的元素。string类型可以是小写字体的string,也可以使大写字体的String。
  使用Collection实现初始化示例
  C#语法允许以一种更加清晰的办法来实现List的初始化。使用collection进行初始化,必须使用大括号{}包围作初始化用的值。下面示例中的注释说明了在执行该程序时编译器所使用的代码。
List初始化示例代码:
1 using S 2 using System.Collections.G 3
4 class Program 5 { 6
static void Main() 7
List&string& moths = new List&string& 9
"African armyworm",11
"Mottled pug",12
"Purple thug",13
"Short-cloaked moth"14
// The List moth contains four strings.16
// List&string& &&g__initLocal0 = new List&string&();19
// &&g__initLocal0.Add("African armyworm");20
// // ... four more Add calls21
// List&string& moths = &&g__initLocal0;22
  解释说明。可以看到字符串列表的初始化编译为调用一系列的Add方法。因此,二者执行起来是相似的。然而,不要超出你的需要来过多的初始化List,因为调用Add方法会增加你的资源消耗。
  Var示例:
  下面是一个关于var关键字如何与List&string&一起使用的示例。var是一个隐式关键字,它与使用全类型名称编译的结果是相同的(var是C# 3.0中新增加的一个关键字,在编译器能明确判断变量的类型时,它允许对本地类型进行推断)。
使用var关键字的List示例:
1 using S 2 using System.Collections.G 3
4 class Program 5 { 6
static void Main() 7
var fish = new List&string&(); // Use var keyword for string List 9
fish.Add("catfish");
// Add string 110
fish.Add("rainbowfish");
fish.Add("labyrinth fish");
fish.Sort();
// Sort string list alphabetically13 14
foreach (string fishSpecies in fish)15
Console.WriteLine(fishSpecies);17
Console.ReadKey();19
catfishlabyrinth fishrainbowfish
  注意。List&string&的Sort方法默认按照字母顺序对其字符串进行排序。它使用替换的方式实现排序,意味着你不必为排序的结果分配新的存储空间。
  上面是字符串类型的List的一些示例。因为C#语言中设计了泛型类型,这些示例中没有花费较大的装箱与拆箱过程,因此,这里的List与ArrayList相比,在任何情况下其效率都要高一些。在这篇文章里,我们学习了声明并使用collection对字符串类型的List进行初始化,还学习了其Sort方法,最后还有一个使用List作为参数的示例程序。
  本文翻译自: 相比原文,译文作了适当修改。
阅读(...) 评论()已有天涯账号?
这里是所提的问题,您需要登录才能参与回答。
"天涯问答"是天涯社区旗下的问题分享平台。在这里您可以提问,回答感兴趣的问题,分享知识和经历,无论您在何时何地上线都可以访问,此平台完全免费,而且注册非常简单。
c#中无法将”int “类型隐式转换为”string“如何解决?
c#中无法将”int “类型隐式转换为”string“如何解决?
09-10-24 & 发布
确实是那样,你case那不能直接用整型的,因为你switch那用的变量是字符串的 所以case那也要用string 对于你这的,你是不是直接用输入的姓名来判断密码是否正确? 那你也可以这样, int myName = Int32.Parse(Console.ReadLine()); 其他不变,直接输入数字看看 不行,你程序有严重的问题···我直接给你修改了,你自己看看 using S using System.Collections.G using System.C using System.L using System.T namespace Temp { class Program { static void Main(string[] args) { bool myBool = do { //获取用户输入的姓名 Console.WriteLine(&请输入姓名:&); Console.WriteLine(&(1)张三(2)李四(3)王五&); int myName = Int32.Parse(Console.ReadLine()); //获取用户输入的密码 Console.WriteLine(&请输入密码:&); string myPassword = Console.ReadLine().Trim(); //根据用户的输入,提示不同的信息 switch (myName) { //当myName等于1时的处理 case 1: if (myPassword == &123456&) { Console.WriteLine(&密码正确&); } else { Console.WriteLine(&密码错误&); }
//当myName等于2时的处理 case 2: if (myPassword == & 234567&) { Console.WriteLine(&密码正确&); } else { Console.WriteLine(&密码错误&); }
//当myName等于3时的处理 case 3: if (myPassword == & 345678&) { Console.WriteLine(&密码正确&); } else { Console.WriteLine(&密码错误&); }
//当myName等于其他时的处理*/ default: Console.WriteLine(&查无此人&);
} } while (!myBool); //当输入为空时,提示退出信息 Console.WriteLine(&没输入有效的姓名,系统将退出……\n按回车键退出程序!&); Console.ReadLine(); } } }
请登录后再发表评论!VS2005无法将类型int隐式转换为string_百度知道
VS2005无法将类型int隐式转换为string
using Susing System.Dusing System.Cusing System.Cusing System.Wusing System.Web.Susing System.Web.UI;using System.Web.UI.WebCusing System.Web.UI.WebControls.WebPusing System.Web.UI.HtmlCusing BLL;public partial class Message_Admin_Configure : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
Settings settings = Configure.GetSettings();
if (settings != null)
this.txtAdminNum.Text = settings.AdminNum.ToString();
//this.txtBookNum.Text = settings.BookNum.ToString();
this.txtEmail.Text = settings.Email.ToString();
this.txtForumNum.Text = settings.ForumNum.ToString();
this.txtName.Text = settings.Name.ToString();
this.ddlModel.SelectedValue = settings.Model.ToString();
protected void btnUpdate_Click(object sender, EventArgs e)
Settings settings = new Settings();
settings.Model = Convert.ToInt32(ddlModel.SelectedValue);
settings.Name = txtName.T
settings.Email = txtEmail.T
settings.ForumNum = Convert.ToInt32(txtForumNum.Text);
settings.AdminNum = Convert.ToInt32(txtAdminNum.Text);
//settings.BookNum = Convert.ToInt32(txtBookNum.Text);
Configure.SaveSettings(settings);
WebHelper.Alert(&配置成功!&);
catch (Exception ex)
WebHelper.Alert(ex.Message.ToString());
提问者采纳
哪一行出错啊,?标注一下,谢谢,~
提问者评价
已经改过来了,不过还是谢谢
其他类似问题
string的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁无法将类型“object”隐式转换为“string”??
[问题点数:20分,结帖人pooyui]
无法将类型“object”隐式转换为“string”??
[问题点数:20分,结帖人pooyui]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
本帖子已过去太久远了,不再提供回复功能。}

我要回帖

更多关于 gt lt eq 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信