Quantcast
Channel: Quickest Method to Reverse in String in C#.net - Stack Overflow
Browsing latest articles
Browse All 12 View Live
↧

Answer by Harry Glinos for Quickest Method to Reverse in String in C#.net

The fastest way I have found to reverse a string in C# is with the following code. It's faster reading in 32bits at a time instead of a char's length of 16bits.In debug mode, it is faster until you get...

View Article


Answer by Matthew Whited for Quickest Method to Reverse in String in C#.net

The Stopwatch class needs reset after each run. the code below has been correctedvar d = s.ToCharArray();Array.Reverse(d);return s == new string(d);using System;using System.Diagnostics;namespace...

View Article


Answer by GateKiller for Quickest Method to Reverse in String in C#.net

Using ggf31416's FastReverse function, here is the solution to Project Euler's Problem #4 which completes on my computer in 47ms.using System;using System.Diagnostics;namespace Euler_Problem_4{ class...

View Article

Answer by configurator for Quickest Method to Reverse in String in C#.net

Wouldn't reversing the number be faster?// unchecked code, don't kill me if it doesn't even compile.ulong Reverse(ulong number) { ulong result = 0; while (number > 0) { ulong digit = number % 10;...

View Article

Answer by ggf31416 for Quickest Method to Reverse in String in C#.net

A you want to compare a number with its reverse it may be faster to reverse the number using division rather than converting it to a string. I still need to test the speed of it. private static int...

View Article


Answer by P Daddy for Quickest Method to Reverse in String in C#.net

I think it might be faster to do the comparison in-place. If you reverse the string, you've got to:Instantiate a new string object (or StringBuffer object)Copy the data (in reverse) from the first...

View Article

Answer by Jesper Palm for Quickest Method to Reverse in String in C#.net

string Reverse(string s){ return new string(s.ToCharArray().Reverse().ToArray());}

View Article

Answer by user53791 for Quickest Method to Reverse in String in C#.net

string test = "ABC";string reversed = new String(test.ToCharArray().Reverse().ToArray());

View Article


Answer by Mladen Prajdic for Quickest Method to Reverse in String in C#.net

try this too:http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx

View Article


Answer by Ed Guiness for Quickest Method to Reverse in String in C#.net

Performance: Fastest string reversing algorithms... (final results)

View Article

Answer by JaredPar for Quickest Method to Reverse in String in C#.net

public static String Reverse(string input) { var length = input.Length; var buffer = new char[length]; for ( var i= 0; i < input.Length; i++ ) { buffer[i] = input[(length-i)-1]; } return new...

View Article

Quickest Method to Reverse in String in C#.net

I'm currently writing a quick solution for Euler Problem #4 where one must find the largest palindromic number from the product of two 3-digit numbers.To identify if a number is palindromic, you would...

View Article
Browsing latest articles
Browse All 12 View Live