找到你要的答案

Q:how to implement android search in windows application desktop vb.net c# sharp

Q:如何在Windows应用程序桌面VB.NET C # Android搜索利器

Here I want to Implement a search like android , like return those Rows of column which any of its word begin with what user search .(Here SQL SERVER , VB.net , Ado.net I am using )

I have a column named suppose ArticleName values Like

  • Mahesh Nagar
  • Manish Nagar
  • Shan mani
  • List item

Ghanshaym rama

Now when i start search 'MA' result would be Mahesh Nagar Manish Nagar Shan mani

Ghanshaym rama should not select as it contains ma but second word not start with ma.

AND when Type "SH" Result would be Shan mani same other rows are exclude because in column value not any of word start with sh

在这里我想实现一个搜索Android一样,像那些排列,其任何字开头的用户搜索。(这里的SQL Server、VB.net、ADO.NET我使用)

我有一个叫作假设articlename价值

  • Mahesh Nagar
  • Manish Nagar
  • Shan mani
  • List item

ghanshaym Rama

Now when i start search 'MA' result would be Mahesh Nagar Manish Nagar Shan mani

ghanshaym Rama should not select as it contains ma but second word not start with ma.

AND when Type "SH" Result would be Shan mani same other rows are exclude because in column value not any of word start with sh

answer1: 回答1:

this solution is fit for my problem

using System;

using System.Collections.Generic;

using System.Linq;

namespace ConsoleApplication2

{

class Program

{

    static void Main(string[] args)

    {

        List<string> lstNames = 

       new List<string>() { "Mahesh Nagar", "Manish Nagar", 

                            "Shan Mani", "Ghanshaym rama" };           

        string toSearch = "Sh";

        string[] stringSeparators = new string[] { " " };

        lstNames

        .ForEach( str=>

           {

                if (str

                        .Split(stringSeparators, StringSplitOptions.None)

                          .Any(i => i.StartsWith(toSearch))

                    )                    

            Console.WriteLine(str.Replace(toSearch, "<b>" + toSearch + "</b>"));                    

          });            

        Console.ReadKey();

    }

}

}

For more details refer this url http://www.dotnetfunda.com/forums/show/20669/how-to-implement-android-search-in-windows-application-desktop-vbnet-c

这个解决方案适合我的问题

使用系统;

使用system.collections.generic;

使用LINQ系统;

命名空间consoleapplication2

{

class Program

{

    static void Main(string[] args)

    {

        List<string> lstNames = 

       new List<string>() { "Mahesh Nagar", "Manish Nagar", 

                            "Shan Mani", "ghanshaym Rama" };           

        string toSearch = "Sh";

        string[] stringSeparators = new string[] { " " };

        lstNames

        .ForEach( str=>

           {

                if (str

                        .Split(stringSeparators, StringSplitOptions.None)

                          .Any(i => i.StartsWith(toSearch))

                    )                    

            Console.WriteLine(str.Replace(toSearch, "<b>" + toSearch + "</b>"));                    

          });            

        Console.ReadKey();

    }

}

}

For more details refer this url http://www.dotnetfunda.com/forums/show/20669/how-to-implement-android-search-in-windows-application-desktop-vbnet-c

android-search