Solved

get last 3 values of array

Posted on 2013-11-11
1
301 Views
Last Modified: 2016-02-10
string col = "a.b.c.e.f.i.1.ff.bb"

how to get the last 3 values using linq or any method

result = "1.ff.bb";
0
Comment
Question by:eoswin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39639648
Hi eoswin;

Try this, it should give you what you need.

string col = "a.b.c.e.f.i.1.ff.bb";

var results = String.Join(".", col.Split(new Char[] {'.'}).Reverse().Take(3).Reverse().ToArray());

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question