Solved

C# array manipulation

Posted on 2011-03-14
2
433 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
2 Comments
 
LVL 74

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Connection String to remote Server not working 3 57
Using Simpleject with Class Library 11 25
ConsoleSql 1 21
String manipulation 15 49
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now