Solved

C# array manipulation

Posted on 2011-03-14
2
439 Views
Last Modified: 2012-05-11
I need a string with concatenated "status code" and "reason code".  Both should be concatenated as shown following. If Status code and reason codes are less than 2 characters, they should be left alligned and a space should be left... If they are more than 2 characters, they should be truncated to 2 characters.

Example:
If account has following status reason codes:
Status Code--Reason Code
AA            -- Y
BU             -- CD
B               -- 9

The result string is “AAY BUCDB 9 “
0
Comment
Question by:vivekj2004
[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
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 35129311
Something like this?
string statusCode = "AA";
string reasonCode = "Y";

string result = string.Concat(statusCode.PadRight(2, ' ').Substring(0, 2), reasonCode.PadRight(2, ' ').Substring(0, 2));

Open in new window

0
 

Author Comment

by:vivekj2004
ID: 35132529
Thanks Kaufmed. 100% solution would be to enclose this in a foreach loop to collect all the status codes.
0

Featured Post

Independent Software Vendors: 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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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