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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:01:00+00:00 2026-06-15T09:01:00+00:00

I often work with arrays of int/float and other things on a regular basis

  • 0

I often work with arrays of int/float and other things on a regular basis in C# since they are faster (maybe?) than List. Currently I’ve got dozens of functions implemented per type:

/// <summary>
/// Checks if the array contains the given value.
/// </summary>
public static bool contains(int[] values, int value) {
    for (int s = 0, sl = values.Length; s < sl; s++) {
        if (values[s] == value) {
            return true;
        }
    }
    return false;
}
/// <summary>
/// Checks if the array contains the given value.
/// </summary>
public static bool contains(float[] values, float value) {
    for (int s = 0, sl = values.Length; s < sl; s++) {
        if (values[s] == value) {
            return true;
        }
    }
    return false;
}

Is there a way to implement these in a generic way? Or is that only possible if I use List<T>?

  • 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-15T09:01:01+00:00Added an answer on June 15, 2026 at 9:01 am

    The System.Array type has a dizzying array of static methods that can help you search, arrange, sort etc your arrays. You definitely do not need to roll your own. These static methods (like Find, FindAll) also accept generic arguments. Here’s the list, dumped with the aid of PowerShell:

    Name                           Definition                    
    ----                           ----------                    
    AsReadOnly                     static System.Collections.... 
    BinarySearch                   static int BinarySearch(ar... 
    Clear                          static void Clear(array ar... 
    ConstrainedCopy                static void ConstrainedCop... 
    ConvertAll                     static TOutput[] ConvertAl... 
    Copy                           static void Copy(array sou... 
    CreateInstance                 static array CreateInstanc... 
    Equals                         static bool Equals(System.... 
    Exists                         static bool Exists[T](T[] ... 
    Find                           static T Find[T](T[] array... 
    FindAll                        static T[] FindAll[T](T[] ... 
    FindIndex                      static int FindIndex[T](T[... 
    FindLast                       static T FindLast[T](T[] a... 
    FindLastIndex                  static int FindLastIndex[T... 
    ForEach                        static void ForEach[T](T[]... 
    IndexOf                        static int IndexOf(array a... 
    LastIndexOf                    static int LastIndexOf(arr... 
    ReferenceEquals                static bool ReferenceEqual... 
    Resize                         static void Resize[T]([ref... 
    Reverse                        static void Reverse(array ... 
    Sort                           static void Sort(array arr... 
    TrueForAll                     static bool TrueForAll[T](... 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often work with multidimensional arrays whose array indices are generated from a complicated
I often work on CSS files or other files that require twiddling numbers. I
I often work in Eclipse, but recently switched to TextMate, which is, in my
As a freelancer, I often work at companies who use Subversion repositories. It’d be
At my company, we develop our ASP.NET applications as websites and often just work
I often like to create backups when testing the software I work on, and
I work on applications developed in C#/.NET with Visual Studio. Very often ReSharper, in
I often want to send sample apps to friends & colleages that work with
At the company that I work with, we often have to integrate with client’s
I am computational scientist that work with large amount of simulation data and often

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.