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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:07:13+00:00 2026-05-27T19:07:13+00:00

there is an array in c# string[] arr = new string[] {1,A,D,3,5,AF,34,TU,E,OP,4}; so how

  • 0

there is an array in c#

string[] arr = new string[] {"1","A","D","3","5","AF","34","TU","E","OP","4"};

so how can i get elements from middle of this array like below

string[] fromArr = new string[5];
fromArr = {"D","3","5","AF","34"};

Do u know any method or any way to do that?

  • 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-27T19:07:14+00:00Added an answer on May 27, 2026 at 7:07 pm

    The simplest way is to use LINQ2Objects

    var fromArr = arr.Skip(2).Take(5).ToArray();
    

    The most performant way would be to use Array.Copy, but that code would be much more cumbersome to write and you need to figure that out yourself, including handling all edge cases when the arrays are not long enough etc.

    But if you will use the result just a few times you don’t need to copy it back to an array, you can just use the lazy evaluation feature of LINQ2SQL

    IEnumerable<string> fromArr = arr.Skip(2).Take(5);
    

    then you can use fromArr in a loop or whatever without even copying the data in the first place.

    When I think about it you may have the option to use ArraySegment<string> too instead of copying to new arrays.

    But for the readability and simplicity, stick with the LINQ version unless you have a real reason to use another alternative.

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

Sidebar

Related Questions

Is there anything more compact (or otherwise better) than this? <x:Array x:Key=titles Type=System:String> <System:String>Mr.</System:String>
Hey, I'm looking to make a loop that takes in this array: String[] arr
I have: Dim arr() As String = {one,two,three} I want a new array, sub
Lets assume we have the following array var arr = new string[] {foo,bar,jar,\r,a,b,c,\r,x,y,z,\r); Also
I need just dictionary or associative array string => int . There is type
There is a string array myDownloadList containing 100 string URIs. I want to start
Is there a built-in function for converting a string array into a dictionary of
Suppose there is a fully populated array of data String[n][3] myData. I want to
Is there a quick way ( existing method) Concatenate array element into string with
suppose there is a string of characters in an array of d[20] . How

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.