Interchanging first and second halves of strings | C # code to create two new strings by swapping first and second halves ; Function to concatenate two different halves of given strings ; Creating new strings by exchanging the first half of a and b . ; Driver Code ; Calling function
using System ; class GFG { static void swapTwoHalves ( string a , string b ) { int la = a . Length ; int lb = b . Length ; string c = a . Substring ( 0 , la / 2 ) + b . Substring ( lb / 2 , lb / 2 + 1 ) ; string d = b . Substring ( 0 , lb / 2 ) + a . Substring ( la / 2 , la / 2 ) ; Console . Write ( c + " STRNEWLINE " + d + " STRNEWLINE " ) ; } static void Main ( ) { string a = " remuneration " ; string b = " day " ; swapTwoHalves ( a , b ) ; } }