Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:21:47+00:00 2026-05-27T12:21:47+00:00

Here I am using Split function to get the parts of string. string[] OrSets

  • 0

Here I am using Split function to get the parts of string.

string[] OrSets = SubLogic.Split('|');
foreach (string OrSet in OrSets)
{
  bool OrSetFinalResult = false;
    if (OrSet.Contains('&'))
    {
        OrSetFinalResult = true;
        if (OrSet.Contains('0'))
        {
            OrSetFinalResult = false;
        }
        //string[] AndSets = OrSet.Split('&');
        //foreach (string AndSet in AndSets)
        //{
        //    if (AndSet == "0")
        //    {
        //        // A single "false" statement makes the entire And statement FALSE
        //        OrSetFinalResult = false;
        //        break;
        //    }
        //}

    }
    else
    {
        if (OrSet == "1")
        {
            OrSetFinalResult = true;
        }
    }

    if (OrSetFinalResult)
    {
        // A single "true" statement makes the entire OR statement TRUE
        FinalResult = true;
        break;
    }
}

How can I replace the Split operation , along with replacement of foreach constructs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:21:48+00:00Added an answer on May 27, 2026 at 12:21 pm

    Hypothesis #1

    Depending of the kind of your process, you can parallellize the work :

    var OrSets = SubLogic.Split('|').AsParallel();
    foreach (string OrSet in OrSets)
    {
      ...
      ....
    }
    

    However, this can often leads to problems with multithreaded apps (locking resource, etc.).
    And you have also to measure the benefits. Switching from one thread to another can be costly. If the job is small, the AsParallel will be slower than a simple sequential loop.

    This is very efficient when you have latency with network resource, or any kind of I/O.

    Hypothesis #2

    Your SubLogic variable is very very very big

    You can, in this case, walk sequentially the file :

    class Program
    {
        static void Main(string[] args)
        {
            var SubLogic = "darere|gfgfgg|gfgfg";
    
            using (var sr = new StringReader(SubLogic))
            {
    
                var str = string.Empty;
                int charValue;
                do
                {
                    charValue = sr.Read();
                    var c = (char)charValue;
                    if (c == '|' || (charValue == -1 && str.Length > 0))
                    {
                        Process(str);
                        str = string.Empty; // Reset the string
                    }
                    else
                    {
                        str += c;
                    }
                } while (charValue >= 0);
    
            }
    
            Console.ReadLine();
        }
    
        private static void Process(string str)
        {
            // Your actual Job
            Console.WriteLine(str);
        }
    

    Also, depending of the length of each chunk between |, you may want to use a StringBuilder and not a simple string concatenation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I call a javascript function from a textbox by using OnKeyPress=clickSearchButton() Here is my
function ip_address_to_number($IPaddress) { if(!$IPaddress) { return false; } else { $ips = split('\.',$IPaddress); return($ips[3]
I'm using the cut function to split my data into groups using the max/min
I'm trying to write a Javascript function to get the query string of the
I'm trying to split a string using the method found in this thread ,
Anybody tried here using Getting Real(37Signals) approach to develop windows application? (C#/.NET). Or simply
Who here is using WASP ( http://wasp.sourceforge.net/content/ ) to in real world applications? What
I have read the post here about using setTimeout() during intensive DOM processing (using
Using Rational ClearCase v. 7.0.1.1 with UCM, I have a problem here when using
what is the value of using IDictionary here?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.