个数组 获取其中字符串包含"2009-11-25"字符串的项 要怎么写了?
比如{abc2009-11-25,asdasd,ad2009-11-25}得到结果 {abc2009-11-25,ad2009-11-25}
请各位高手帮忙!谢谢
比如{abc2009-11-25,asdasd,ad2009-11-25}得到结果 {abc2009-11-25,ad2009-11-25}
请各位高手帮忙!谢谢
解决方案 »
- 权限,修改与查询功能
- 求助:一个性能改善的问题
- 请问怎么设置Guid.NewGuid().tostring()的格式
- 帮忙看看这句SQL语句问题,顶了有分啊
- 提交更新数据的区别
- 请问在C#中如何取得一个颜色的反色??????
- 困难的产品字段显示?我该怎么办
- 求用户注册代码!!
- 大家介绍一个简单的文本编辑控件吧.freetextbox和fck都太麻烦了,特别是图片上传功能.立马给分!
- dataservice的问题 我用这种技术实现了 直接通过地址栏访问数据库
- AspxGridviw放入了一个AspxCombobox,对AspxCombobox赋值报错??
- 网站的ClickOnce自动部署,有必要吗?
string[] sArr = { ... }; //原数组
List<string> list = new List<string>(); //筛选后的新数组
foreach (string s in sArr)
{
if (s.Contains("2009-11-25"))
list.Add(s);
}
using System.Collections.Generic;class Program
{
static void Main()
{
string pattern = "2009-11-25"; // <-- 要寻找的样式
string[] a = { "abc2009-11-25", "asdasd", "ad2009-11-25" };
List<string> l = new List<string>();
foreach (string s in a)
{
if (s.Contains(pattern)) l.Add(s);
}
string[] b = l.ToArray(); // <-- 这就是你要的字符串数组! foreach (string s in b)
{
Console.WriteLine(s);
}
}
}
public class Test {
public static void main(String[] args) { String[] strs = {"abc2009-11-25","asdasd","ad2009-11-25"};
String str = "2009-11-25";
ArrayList<String> list = new ArrayList<String>();
for(String str1: strs){
if(str1.indexOf(str)>0){
list.add(str1);
}
}
System.out.println(list);
}
}
ArrayList arr = new ArrayList();
foreach(string va in ss)
{
if(va.indexof('2009-11-25')!=-1)
arr.Add(va);
}
for(int i=0;i<arr.length;arr++)
{
response.write(arr[i]);
}
{
string str = "abc2009-11-25,asdasd,ad2009-11-25";
string[] st = str.Split(',');
List<string> number = new List<string>();
for (int i = 0; i < st.Length; i++)
{
if (st[i].Contains("2009-11-25"))
{
number.Add(st[i]);
}
}
string bb = "";
if(number!=null)
{
foreach (string s in number)
{
bb+=s;
}
Response.Write("<script>alert('"+bb+"');</script>");
}
}
不知道是不是你想要的效果