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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:52:03+00:00 2026-05-16T18:52:03+00:00

I have string[] pkgratio= 1:2:6.Split(‘:’); var items = pkgratio.OrderByDescending(x => x); I want to

  • 0

I have

string[] pkgratio= "1:2:6".Split(':');

var items = pkgratio.OrderByDescending(x => x);

I want to select the middle value and have come up with this. Is this a correct way to select the second value in an IEnumberable?

pkgratio.Skip(1).Take(1).First();
  • 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-16T18:52:03+00:00Added an answer on May 16, 2026 at 6:52 pm

    While what you have works, the most straightforward way would be to use the array’s index and reference the second item (at index 1 since the index starts at zero for the first element): pkgratio[1]

    Console.WriteLine(pkgratio[1]);
    

    A more complete example:

    string[] pkgratio = "1:2:6".Split(':');
    
    for (int i = 0; i < pkgratio.Length; i++)
        Console.WriteLine(pkgratio[i]);
    

    With an IEnumerable<T> what you have works, or you could directly get the element using the ElementAt method:

    // same idea, zero index applies here too
    var elem = result.ElementAt(1);
    

    Here is your sample as an IEnumerable<string>. Note that the AsEnumerable() call is to emphasize the sample works against an IEnumerable<string>. You can actually use ElementAt against the string[] array result from Split, but it’s more efficient to use the indexer shown earlier.

    var pkgratio = "1:2:6".Split(':').AsEnumerable();
    Console.WriteLine(pkgratio.ElementAt(1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have string like this : <input name=my_name id=my_id value=my_value class=my_class /> I would
I have string like this var str = #it itA itB _ #et etA
I have string which contains every word separated by comma. I want to split
I have string like this 0 0.014E5 and I need it split into a
I have string in the following format. Option1:Option2:Option3:Option4 I want to get these items
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I have string like this (length>10)&(length<100) And i want this (,length,>,10,),&,(,length,<,100,) Is it possible
I have string and want to capture a fragment by regex as: var regex
I have string that look like Array that fetched from other webservice like this

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.