Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
GeneralRe: Discussion : Can we say Overloading as polymorphism Pin
Nagy Vilmos9-Apr-09 1:46
professionalNagy Vilmos9-Apr-09 1:46 
GeneralRe: Discussion : Can we say Overloading as polymorphism Pin
dojohansen9-Apr-09 2:46
dojohansen9-Apr-09 2:46 
GeneralRe: Discussion : Can we say Overloading as polymorphism Pin
Rob Philpott8-Apr-09 22:55
Rob Philpott8-Apr-09 22:55 
GeneralRe: Discussion : Can we say Overloading as polymorphism Pin
Cracked-Down8-Apr-09 23:20
Cracked-Down8-Apr-09 23:20 
GeneralRe: Discussion : Can we say Overloading as polymorphism Pin
dojohansen9-Apr-09 3:04
dojohansen9-Apr-09 3:04 
QuestionString manipulation with large strings [modified] Pin
Harvey Saayman8-Apr-09 22:17
Harvey Saayman8-Apr-09 22:17 
AnswerRe: String manipulation with large strings Pin
Rob Philpott8-Apr-09 22:52
Rob Philpott8-Apr-09 22:52 
GeneralRe: String manipulation with large strings Pin
Harvey Saayman8-Apr-09 23:13
Harvey Saayman8-Apr-09 23:13 
Rob Philpott wrote:
I can offer no solution to that, but might suggest that rather than 'Removing' parts from such a huge string you either iterate over it to get what you need or just copy substrings.


Here's what happens exactly

After i get a server response from a TCP connection, the listener thread sends back all that data via a callback. Now one of these callbacks may have more than one command in it.

Each command starts with ln=[length of command][terminator]

So I loop to find a ln=, when I do I remove it, and then parse the length of the command to come. Then I take that command out (sub string it so i can pass it to another method), and remove it from the pool of commands so that the loop may continue in case there's another command to execute. Here's the full methods code

// This method is called from a different thread
private void ProcessMessage(string CommandPool)
{
    RawResponseReceived(CommandPool);

    while (CommandPool != string.Empty)
    {
        //
        // If the command starts with a ln=
        if (CommandPool.StartsWith("ln="))
        {
            //
            // Remove the ln=
            CommandPool = CommandPool.Remove(0, 3);

            //
            // Get the length of the command

            int RequestSize = -1;
            string FinalLength = string.Empty;

            while (Int32.TryParse(CommandPool[0].ToString(), out RequestSize))
            {
                FinalLength += RequestSize.ToString();
                CommandPool = CommandPool.Remove(0, 1);
            }

            //
            // Parse the request size
            RequestSize = Int32.Parse(FinalLength);

            //
            // remove the terminator at the start
            CommandPool = CommandPool.Remove(0, 1);

            //
            // get the individual command
            string command = CommandPool.Substring(0, RequestSize);

            //
            // remove command from the command pool
            CommandPool = CommandPool.Remove(0, RequestSize);

            //
            // send command away for proccessing
            ProcessCommand(command);
        }
        else
        {
            Console.Write("Char removed - " + CommandPool[0]);
            CommandPool = CommandPool.Remove(0, 1);
        }
    }
}

NOTE: I just changed some of the variable names to make it more readable

The reason these strings are so big sometimes, is that I'm getting binary data in it aswel. Can this be causing the problems?

Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL

you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

GeneralRe: String manipulation with large strings Pin
Rob Philpott8-Apr-09 23:24
Rob Philpott8-Apr-09 23:24 
GeneralRe: String manipulation with large strings Pin
Harvey Saayman8-Apr-09 23:38
Harvey Saayman8-Apr-09 23:38 
GeneralRe: String manipulation with large strings Pin
dojohansen8-Apr-09 23:58
dojohansen8-Apr-09 23:58 
GeneralRe: String manipulation with large strings Pin
Harvey Saayman9-Apr-09 0:30
Harvey Saayman9-Apr-09 0:30 
GeneralRe: String manipulation with large strings Pin
dojohansen9-Apr-09 1:14
dojohansen9-Apr-09 1:14 
GeneralRe: String manipulation with large strings Pin
dojohansen9-Apr-09 1:25
dojohansen9-Apr-09 1:25 
JokeRe: String manipulation with large strings Pin
dojohansen9-Apr-09 1:37
dojohansen9-Apr-09 1:37 
Questionhow to select the text from the dropdownlist Pin
mdazeemuddin8-Apr-09 22:03
mdazeemuddin8-Apr-09 22:03 
QuestionPenel in Status Bar [modified] Pin
Sajjad Leo8-Apr-09 21:16
Sajjad Leo8-Apr-09 21:16 
AnswerRe: Penel in Status Bar Pin
DaveyM698-Apr-09 22:09
professionalDaveyM698-Apr-09 22:09 
GeneralRe: Penel in Status Bar Pin
Sajjad Leo8-Apr-09 23:19
Sajjad Leo8-Apr-09 23:19 
GeneralRe: Penel in Status Bar Pin
DaveyM699-Apr-09 0:11
professionalDaveyM699-Apr-09 0:11 
GeneralRe: Penel in Status Bar Pin
Sajjad Leo12-Apr-09 20:28
Sajjad Leo12-Apr-09 20:28 
QuestionMedia player control Pin
yesu prakash8-Apr-09 20:44
yesu prakash8-Apr-09 20:44 
AnswerRe: Media player control Pin
12Code8-Apr-09 20:52
12Code8-Apr-09 20:52 
QuestionHelp to me to find simple method for days of month Pin
M Riaz Bashir8-Apr-09 20:30
M Riaz Bashir8-Apr-09 20:30 
AnswerRe: Help to me to find simple method for days of month Pin
DaveyM698-Apr-09 20:37
professionalDaveyM698-Apr-09 20:37 

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.