Click here to Skip to main content
13,045,657 members (51,782 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I need to concat two strings such that the second string must be placed at the 19th digit position from the beginning.

Example: Let us, two strings are "Mumbai" & "Delhi".Let the concatenation happen.Then, Delhi's "D" must be placed at 19th position from the first letter of Mumbai,i.e.,"M".
Lets replace "Mumbai" with "Kolkata". Then after concatenation, Delhi's "D" must be placed at 19th position from First letter of "Kolkata",i.e.,"K".

Can Anyone Help me to achieve this? Thanks in advance.
Posted 28-Apr-13 8:09am
Updated 28-Apr-13 8:11am
ThePhantomUpvoter 28-Apr-13 14:12pm
You could probably make use of the PadRight function to do this.
Sergey Alexandrovich Kryukov 28-Apr-13 15:30pm
First, why? Second, what have you done so far?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can use this approach too:

var s1 = "Mumbai";
var s2 = "Delhi";
Console.WriteLine(string.Format(string.Format("{{0}} {{1,{0}}}",19-s1.Length),s1,s2));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100