Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Reverse And Shift Char in String
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Globalization; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { CultureInfo ci = new CultureInfo("hi-IN"); var numbers = new List<string>(); numbers.Add(11223344556677889900.ToString("N0",ci)); numbers.Add(10000000000000000000.ToString("N0",ci)); for(var i = 0; i < numbers.Count; i++){ numbers[i] = ShiftString(numbers[i]); Console.WriteLine((numbers[i])); } Console.Write(ReverseString(numbers[0])); } public static string ShiftString(string t) { string result = string.Empty; bool comma = false; foreach(var chr in t){ if(chr == ','){ comma = true; continue; } result += chr+(comma ? "," : ""); comma = false; } return result; } ///Recursion method; simple and regular performance for small strings public static string ReverseString(string str) { if (str.Length <= 1) return str; else return ReverseString(str.Substring(1)) +str[0]; } } }
run
|
edit
|
history
|
help
0
display xml : linq
30272 Example2
Pascal Tringle
Plantera mas com escolhas
Find median in a stream
tester of xpath
null enum value check is false
aaaaa
Vin Generator V1
memes