Click here to Skip to main content
15,917,652 members
Home / Discussions / C#
   

C#

 
GeneralSending (and then handling) messages to a server Pin
Completenutter215-Jan-08 0:00
Completenutter215-Jan-08 0:00 
GeneralZooming in chart... Pin
amoldix14-Jan-08 23:34
amoldix14-Jan-08 23:34 
GeneralRe: Zooming in chart... Pin
S. Senthil Kumar15-Jan-08 7:42
S. Senthil Kumar15-Jan-08 7:42 
Questionchange video border color when using WMP in C# Pin
codefreaklcs14-Jan-08 23:30
codefreaklcs14-Jan-08 23:30 
QuestionCount bitpattern occurences in textstrings Pin
invictus314-Jan-08 21:40
invictus314-Jan-08 21:40 
GeneralRe: Count bitpattern occurences in textstrings Pin
J4amieC14-Jan-08 22:33
J4amieC14-Jan-08 22:33 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus314-Jan-08 23:00
invictus314-Jan-08 23:00 
AnswerRe: Count bitpattern occurences in textstrings Pin
Ajay.k_Singh14-Jan-08 23:11
Ajay.k_Singh14-Jan-08 23:11 
If you want to search for a particular bit pattern within a string, you will first need to convert string to a byte array, this can be done using System.Text.ASCIIEncoding object.

After converting string to byte array we may search this array for a particular bit pattern. Following is a code snippet which will give you some idea about this-

---------------------Code Start-------------------

byte[] bytes;

byte pattern1 = 111;

string str = "hello there how are you";


System.Text.ASCIIEncoding getencoding = new ASCIIEncoding();

//convert string to byte array

bytes = getencoding.GetBytes(str);

int i;

for (i = 0; i < str.Length; i++)

{



if (bytes.GetValue(i).Equals(pattern1))
{

MessageBox.Show("");

}

}
------------------------Code End---------------

I hope this helps Smile | :) .

-Dave.

Dave Traister,
ComponentOne LLC.
www.componentone.com

GeneralRe: Count bitpattern occurences in textstrings Pin
invictus314-Jan-08 23:29
invictus314-Jan-08 23:29 
GeneralRe: Count bitpattern occurences in textstrings Pin
Russell Jones15-Jan-08 0:02
Russell Jones15-Jan-08 0:02 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus315-Jan-08 0:05
invictus315-Jan-08 0:05 
GeneralRe: Count bitpattern occurences in textstrings Pin
Russell Jones15-Jan-08 0:45
Russell Jones15-Jan-08 0:45 
GeneralRe: Count bitpattern occurences in textstrings [modified] Pin
Luc Pattyn15-Jan-08 0:56
sitebuilderLuc Pattyn15-Jan-08 0:56 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus315-Jan-08 23:20
invictus315-Jan-08 23:20 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn16-Jan-08 8:56
sitebuilderLuc Pattyn16-Jan-08 8:56 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus319-Jan-08 8:41
invictus319-Jan-08 8:41 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn19-Jan-08 9:13
sitebuilderLuc Pattyn19-Jan-08 9:13 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus319-Jan-08 11:16
invictus319-Jan-08 11:16 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn19-Jan-08 11:36
sitebuilderLuc Pattyn19-Jan-08 11:36 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus319-Jan-08 12:57
invictus319-Jan-08 12:57 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn19-Jan-08 14:01
sitebuilderLuc Pattyn19-Jan-08 14:01 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus321-Jan-08 0:09
invictus321-Jan-08 0:09 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn21-Jan-08 0:45
sitebuilderLuc Pattyn21-Jan-08 0:45 
GeneralRe: Count bitpattern occurences in textstrings Pin
invictus321-Jan-08 0:57
invictus321-Jan-08 0:57 
GeneralRe: Count bitpattern occurences in textstrings Pin
Luc Pattyn21-Jan-08 1:09
sitebuilderLuc Pattyn21-Jan-08 1:09 

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.