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 6763507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:02+00:00 2026-05-26T14:29:02+00:00

I have a C# program that maps legacy text file report to an excel

  • 0

I have a C# program that maps legacy text file report to an excel sheet. it works but it takes too long to run.
I wasn’t sure how but i read that one problem is using the IF statement that I should change that to the SWITCH clause. How do i do that?
here is a typical case.

     else if (line.Contains("BILLING PARTY 1")) {
                        string billingParty1 = line.Replace("BILLING PARTY 1", "");
                        if (!string.IsNullOrWhiteSpace(billingParty1)){
                            patient.BillingParty1 = billingParty1.Trim();
                        }
                    }
  • 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-26T14:29:03+00:00Added an answer on May 26, 2026 at 2:29 pm

    That advice doesn’t look like it applies here. You can use a switch statement to replace a long chain of ifs where you are checking to see if a field matches some value. For example:

    if(foo == bar){
        Do1();
    }
    else if(foo == baz){
        Do2()
    }
    

    becomes

    switch(foo)
    {
        case bar:
           Do1();
           break;
        case baz:
           Do2();
           break;
    }
    

    In this case, it’s likely the compiler could generate faster code. But it seems like you have some more complicated conditions in your if statements as opposed to simple equality, so you won’t be able to use a switch, because in a switch,

    Each case label specifies a constant value.

    MS Ref

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

Sidebar

Related Questions

I have a C# program that takes a legacy report file and maps to
I have a C# program that takes a text file of a legacy report
I have a program that takes as input an array of lat/long points. I
We have a program that displays map data (think Google Maps, but with much
I have a program that spits out an Excel workbook in Excel 2003 XML
I have a program that I am writing, not too big. Apart from the
I have a program that uses the win32com library to control iTunes, but have
I have a program that I want to use google maps for. The problem
I have a program that takes in a zip code and makes a google
I'm writing a program that reads a text file of city names into a

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.