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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:29:31+00:00 2026-05-16T00:29:31+00:00

I have a class: public class MyObject { public string Code; public string FullName;

  • 0

I have a class:

public class MyObject
{
public string Code;
public string FullName;
}

I have a List of Myobject objects:

Code FullName
"ABC" "The abc company"
"BBC" "The bbc company"
"CPA" "The cpa company"

My requirement: a matched condition is a Code or FullName contains input word. With matched records, I will sort on Code before and FullName later.

Example:

When user input a string: “bc”, return a list:

Code FullName
"ABC" "The abc company"
"BBC" "The bbc company"

When user input a string: “pa”, return this list (note that "PA" is part of the Code, so it is displayed first):

Code FullName
"CPA" "The cpa company"
"ABC" "The abc company"
"BBC" "The bbc company"

Explain: When sorting, the Code field is more Priority than FullName field. Because, all of records contains the string “pa” but only the record with Code “CPA” contain “pa”, so it must be above.

PS: I’m using .NET 2.0/C# 2.0. String compare in filtering is not case-sensitive.

  • 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-16T00:29:31+00:00Added an answer on May 16, 2026 at 12:29 am

    I’d do the following:

    1. create an array of integers that has the same length as your array of companies
    2. iterate over all the companies
    3. test to see if the company code starts with user input, if yes, add 1000 to the int array at the current index.
    4. test to see if the company code contains the user input, if yes, add 100 to the int array at the current index
    5. test to see if the company fullname contains the user input, if yes, add 10 to the int array at the current index.
    6. (add additional tests, in my string search system I ended up having 7 distinct matchings)
    7. sort the company array using the int array as keys
    8. return the first N results from the sorted array, or all results, or all results that have a key larger than 0.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine I have an entity: public class MyObject { public string Name { get;
Suppose I have the following: public class MyObject { public string Name {get; set;}
In code, class MyObject { public String doThing() { return doh; } } class
Given: I have a class: class MyObject { public string Field1; public string Field2;
I have an object like this: class MyObject { public string Object.Prop1 { get;
I have class with back reference: public class Employee : Entity { private string
i have a class: public class Vars { public static final String NAME =
i have this class public class Image { public string url { get; set;
public class Currency{ private Code {get;set;} public Currency(string code){ this.Code = code; } //more
I have read a parent Class called MyClass code like this, public class MyClass

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.