using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication11
{
static class Program
{
static void Main(string[] args)
{
string full = "Bacliff New Texas United States";
ArrayList list = new ArrayList();
ArrayList newlist = new ArrayList();
// split the string in words
string[] words = full.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
List<Info> infoList = new List<Info>();
ArrayList res = new ArrayList();
int k = 1;
for (int size = 1; size < words.Length; ++size)
{
// get substrings of 'size' words
for (int start = 0; start <= words.Length - size; ++start)
{
string[] before = new string[start];
string[] destination = new string[size];
string[] after = new string[words.Length - (size + start)];
Array.Copy(words, 0, before, 0, before.Length);
Array.Copy(words, start, destination, 0, destination.Length);
Array.Copy(words, start + destination.Length, after, 0, after.Length);
list.Add(string.Join(" ", before));
list.Add(string.Join(" ", destination));
list.Add(string.Join(" ", after));
}
}
var clone = (from string item in list
where item != string.Empty
select item).GroupBy(s => s).Select(
group => new { Word = group.Key, Count = group.Count() }).Where(x => x.Count >=2);
foreach (var duplicate in clone)
{
newlist.Add(duplicate.Word);
}
}
public class Info
{
public int sno { get; set; }
public string strVal { get; set; }
}
}
}
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication11
{
static class Program
{
static void Main(string[] args)
{
string full = "Bacliff New Texas United States";
ArrayList list = new ArrayList();
ArrayList newlist = new ArrayList();
// split the string in words
string[] words = full.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
List<Info> infoList = new List<Info>();
ArrayList res = new ArrayList();
int k = 1;
for (int size = 1; size < words.Length; ++size)
{
// get substrings of 'size' words
for (int start = 0; start <= words.Length - size; ++start)
{
string[] before = new string[start];
string[] destination = new string[size];
string[] after = new string[words.Length - (size + start)];
Array.Copy(words, 0, before, 0, before.Length);
Array.Copy(words, start, destination, 0, destination.Length);
Array.Copy(words, start + destination.Length, after, 0, after.Length);
list.Add(string.Join(" ", before));
list.Add(string.Join(" ", destination));
list.Add(string.Join(" ", after));
}
}
var clone = (from string item in list
where item != string.Empty
select item).GroupBy(s => s).Select(
group => new { Word = group.Key, Count = group.Count() }).Where(x => x.Count >=2);
foreach (var duplicate in clone)
{
newlist.Add(duplicate.Word);
}
}
public class Info
{
public int sno { get; set; }
public string strVal { get; set; }
}
}
}