Click here to Skip to main content
15,888,816 members
Home / Discussions / C#
   

C#

 
GeneralRe: Update Cache Data Pin
sjs4u8-Sep-09 2:38
sjs4u8-Sep-09 2:38 
QuestionGet the automated changes from excel Pin
NarVish8-Sep-09 2:09
NarVish8-Sep-09 2:09 
QuestionSearch for repeated character combinations Pin
khalidelmeknesi8-Sep-09 2:07
khalidelmeknesi8-Sep-09 2:07 
AnswerRe: Search for repeated character combinations Pin
sanforjackass8-Sep-09 2:58
sanforjackass8-Sep-09 2:58 
GeneralRe: Search for repeated character combinations Pin
khalidelmeknesi8-Sep-09 3:08
khalidelmeknesi8-Sep-09 3:08 
AnswerRe: Search for repeated character combinations [modified] Pin
sanforjackass8-Sep-09 4:00
sanforjackass8-Sep-09 4:00 
GeneralRe: Search for repeated character combinations [modified] Pin
khalidelmeknesi16-Sep-09 22:48
khalidelmeknesi16-Sep-09 22:48 
AnswerRe: Search for repeated character combinations Pin
sanforjackass18-Sep-09 12:05
sanforjackass18-Sep-09 12:05 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CountString
{
class Program
{
static void Main(string[] args)
{
string _givenString = "wvtnfhxyz1hdxyz1fdxyz1ejxyz1dhxyz1dxyzeeaa1oeys";
Dictionary<string, int> _codes = new Dictionary<string, int>();
int _startingPoint = 0;
//while (_startingPoint < _givenString.Length)
//{
for (int j = 2; j < _givenString.Length; j++)
{
for (int i = _startingPoint; i < _givenString.Length && i + j < _givenString.Length+1; i++)
{
if (!_codes.ContainsKey(_givenString.Substring(i, j)))
{
_codes.Add(_givenString.Substring(i, j), 1);
}
else
{
_codes[_givenString.Substring(i, j)] += 1;
}
}
}
// _startingPoint++;
//}

List<KeyValuePair<string, int>> _sortedCodes = SortDictionary(_codes);
for (int i = 0; i < 5; i++)
{
Console.WriteLine(_sortedCodes[i].Key + " : " + _sortedCodes[i].Value + " times");
}
Console.ReadKey();
}

public static List<KeyValuePair<string, int>> SortDictionary(Dictionary<string, int> data)
{
List<KeyValuePair<string, int>> result =
new List<KeyValuePair<string, int>>(data);
result.Sort(
delegate(
KeyValuePair<string, int> first,
KeyValuePair<string, int> second)
{
return second.Value.CompareTo(first.Value);
}
);
return result;
}
}
}

does it work as you want??
AnswerRe: Search for repeated character combinations Pin
Ian Shlasko8-Sep-09 5:41
Ian Shlasko8-Sep-09 5:41 
GeneralRe: Search for repeated character combinations Pin
khalidelmeknesi8-Sep-09 21:48
khalidelmeknesi8-Sep-09 21:48 
QuestionRedirect Console for In-Memory Execution Pin
Anindya Chatterjee8-Sep-09 1:49
Anindya Chatterjee8-Sep-09 1:49 
AnswerRe: Redirect Console for In-Memory Execution Pin
Not Active8-Sep-09 2:19
mentorNot Active8-Sep-09 2:19 
GeneralRe: Redirect Console for In-Memory Execution Pin
Anindya Chatterjee8-Sep-09 3:27
Anindya Chatterjee8-Sep-09 3:27 
GeneralRe: Redirect Console for In-Memory Execution Pin
Not Active8-Sep-09 3:36
mentorNot Active8-Sep-09 3:36 
GeneralRe: Redirect Console for In-Memory Execution Pin
Anindya Chatterjee8-Sep-09 3:43
Anindya Chatterjee8-Sep-09 3:43 
GeneralRe: Redirect Console for In-Memory Execution Pin
Not Active8-Sep-09 4:14
mentorNot Active8-Sep-09 4:14 
Questionhow to change individual gridline color in datagridview Pin
gtag8-Sep-09 1:48
gtag8-Sep-09 1:48 
QuestionXML tags for documentation: How to link to data type of parameter / function? Pin
Guido Carl8-Sep-09 1:24
Guido Carl8-Sep-09 1:24 
AnswerRe: XML tags for documentation: How to link to data type of parameter / function? Pin
N a v a n e e t h8-Sep-09 2:11
N a v a n e e t h8-Sep-09 2:11 
AnswerRe: XML tags for documentation: How to link to data type of parameter / function? Pin
Guido Carl8-Sep-09 2:19
Guido Carl8-Sep-09 2:19 
QuestionContext menu or Context menu with Icons Pin
rizwan.saddal8-Sep-09 1:02
rizwan.saddal8-Sep-09 1:02 
AnswerRe: Context menu or Context menu with Icons Pin
DaveyM698-Sep-09 1:11
professionalDaveyM698-Sep-09 1:11 
Questioniphone style scrolling Pin
benams8-Sep-09 0:47
benams8-Sep-09 0:47 
AnswerRe: iphone style scrolling Pin
Alan Balkany8-Sep-09 4:23
Alan Balkany8-Sep-09 4:23 
QuestionWinForm Opacity - BeginDrag / EndDrag Pin
Programm3r8-Sep-09 0:19
Programm3r8-Sep-09 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.