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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:37:37+00:00 2026-05-21T07:37:37+00:00

This is a real performance problem. public int FindPreviousFC(int framecode) { if (SetTable ==

  • 0

This is a real performance problem.

public int FindPreviousFC(int framecode)
    {
        if (SetTable == null)
            throw new NullReferenceException("Not loaded  Log_Roadb.");
        int previousFrameCode = 0;
        for (int i = 0; i < SetTable.Rows.Count; i++)
        {
            if (framecode == Convert.ToInt32(SetTable.Rows[i][0]))
            {
                previousFrameCode = Convert.ToInt32(SetTable.Rows[i - 1][0]);
                break;
            }
        }
        return previousFrameCode;
    }
  • 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-21T07:37:38+00:00Added an answer on May 21, 2026 at 7:37 am

    If the data in the SetTable is ordered on framecode than you can use a binary search through the data structure to reduce the number of lookups.

    If there are not patterns in the data that you can exploit optimizing performance may become tricky. This assumes that you can’t export the data from SetTable into a structure where lookups are faster.

    If this Find method is being called frequently on the same set of data, then you may also want to consider creating an index structure (dictionary) to speed up subsequent lookups. This may mitigate the cost of iterating over the same data over and over.


    Also, as an aside, don’t throw a NullReferenceException when you check the SetTable argument, throw ArgumentNullExeception instead. Null reference exceptions are thrown by the CLR when a reference variable that is null is dereferenced … it shouldn’t be thrown by your code.

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

Sidebar

Related Questions

Note: this is not real information: $ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private
This is not a real bug BUT for sure it is not what you
If this is not a real question then feel free to close ;)
We have a very high performance multitasking, near real-time C# application. This performance was
This is more a programming exercise than a real-world problem: I am looking for
In a .f file there is code that does this: real Bob, avar ...
This is a real newbie question. I have simple app that selects a picture
This one is a real head scratcher for me... var matches = Regex.Matches(<p>test something<script
So this should be a real easy question but I can't seem to find
This doesn't need to be a real time solution, but are there some log

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.