Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
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 9:09am
Edited 28-Apr-13 9:11am
ThePhantomUpvoter at 28-Apr-13 14:12pm
You could probably make use of the PadRight function to do this.
Sergey Alexandrovich Kryukov at 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
0 Sergey Alexandrovich Kryukov 535
1 OriginalGriff 275
2 BillWoodruff 260
3 Shweta N Mishra 244
4 Deepu S Nair 230
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,818
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,755

Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 28 Apr 2013
Copyright © CodeProject, 1999-2014
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