C # program to print consecutive characters together in a line .
using System ; class GFG { static void print ( String str1 ) { char [ ] str = str1 . ToCharArray ( ) ; Console . Write ( str [ 0 ] ) ; for ( int i = 1 ; i < str . Length ; i ++ ) { if ( ( str [ i ] == str [ i - 1 ] + 1 ) || ( str [ i ] == str [ i - 1 ] - 1 ) ) { Console . Write ( str [ i ] ) ; } else { Console . Write ( " STRNEWLINE " + str [ i ] ) ; } } }