简体   繁体   English

C#编译错误

[英]C# Compile Error

int[] ddfv = DropDownList1.SelectedItem.Value.ToString().Split('_').Select(part => int.Parse(part, System.Globalization.NumberStyles.Integer)).ToArray();

error : there is no .Select in String [] :( 错误:在字符串[]中没有.Select :(

there is a value like "1_2" I need to save 1 and 2 as integer values :) 有一个像“ 1_2”的值,我需要将1和2保存为整数值:)

Select is an extension method, defined in the System.Linq namespace. Select是在System.Linq命名空间中定义的扩展方法。

The reason for the error is probably one of these: 错误的原因可能是以下之一:

  • you are missing the reference to the assembly System.Core 您缺少对程序集System.Core的引用
  • you are missing the using directive for Linq ( using System.Linq; ) 您缺少Linq的using指令( using System.Linq;
  • you are not using .NET 3.x 您没有使用.NET 3.x

int[] value = DropDownList1.SelectedItem.Value.ToString().Split('_'); int []值= DropDownList1.SelectedItem.Value.ToString()。Split('_'); in the above "value" contains all split values, use index to fetch respective values ex: if DropDownList selected values is course_name_123 so i want only character before _ use the first line code and value[0] contains ur new data 在上面的“值”中包含所有拆分值,请使用索引来获取相应的值,例如:如果DropDownList选择的值是course_name_123,那么我只希望字符_使用第一行代码,而value [0]包含您的新数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM