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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:37:24+00:00 2026-06-03T13:37:24+00:00

Hello I have one question about using genetic in correct way. please look at

  • 0

Hello I have one question about using genetic in correct way.

please look at my code, I need an advise, is it possible to create basic search in some other way. I would like to remove ISearcher impementation from Conc2Search and Conc1Search classes.

class Program
{
    static void Main(string[] args)
    {
         var res1 = SearchCreator.GetSearch(1).Search();
         Console.WriteLine("GenetalSearch count:{0}", res1.Count());

         var res2 = SearchCreator.GetSearch(2).Search();
         Console.WriteLine("Conc1Search count:{0}", res2.Count());

         var res3 = SearchCreator.GetSearch(3).Search();
         Console.WriteLine("Conc2Search count:{0}", res3.Count());
    }

    public class SearchCreator
    {           
         public static ISearcher<Base> GetSearch(int type)
         {
             switch (type)
             {
                 case 1: return new GenetalSearch();
                 case 2: return new Conc1Search();
                 case 3: return new Conc2Search();
             }
             return null;
         }
    }
}


public class Base
{

}

public class Conc1 : Base
{

}

public class Conc2 : Base
{

}

public interface ISearcher<out T> where T : Base
{
    IEnumerable<T> Search();
}


public class GenetalSearch : ISearcher<Base>
{
    public IEnumerable<Base> Search()
    {
         var list = new List<Base> {new Base(), new Base(), new Base()};
         return list;
    }
}

public class Conc1Search : ISearcher<Conc1>, ISearcher<Base>
{
     public IEnumerable<Conc1> Search()
     {
         var list = new List<Conc1>() { new Conc1(), new Conc1(), new Conc1(), new Conc1()};
         return list;
     }

     IEnumerable<Base> ISearcher<Base>.Search()
     {
         return Search();
     }
}

public class Conc2Search : ISearcher<Conc2>, ISearcher<Base>
{
     public IEnumerable<Conc2> Search()
     {
         var list = new List<Conc2>() { new Conc2(), new Conc2(), new Conc2(), new Conc2(), new Conc2() };
         return list;
     }

     IEnumerable<Base> ISearcher<Base>.Search()
     {
         return Search();
     }
}
  • 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-06-03T13:37:29+00:00Added an answer on June 3, 2026 at 1:37 pm

    What about:

    public interface ISearcher<T>
    {
        IEnumerable<T> Search();
    }
    
    public class GeneralSearch<T> : ISearcher<T> where T : new()
    {
        public static IEnumerable<T> Search()
        {
            var list = new List<T> { new T(), new T(), new T() };
            return list;
        }
    }
    

    And then for example:

    IEnumerable<myClass> test = GeneralSearch<myClass>.Search();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Can Any one have idea about below code and its related error. code:
Hello every one I want to ask a question about file transfer using sockets.
Hello I am new to python and have a question about the best/pythonic way
hello I have some question about writing class in Java, why this one is
I have one requirement in C. char abc[]=hello; char hello[]=world; Using abc whether we
Hello every one I have wrote a simple code in html5 in which I
Hello I need split a String by . Have : $string = Step one
Hello guys I have a specific question about the AND clause in SQL. The
Hello everybody Well my question is about sql commands... If I have 2 tables
I have a quick question about the two examples below. Currently I am using

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.