Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
test_hash
//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.Text.RegularExpressions; namespace Rextester { public class Program { public static char PathSeparatorChar { get { return '/'; } } public static string PathSeparatorString { get { return "/"; } } public static char AltPathSeparatorChar { get { return '\\'; } } public static readonly char[] pathSeparatorChars = new[] {PathSeparatorChar, AltPathSeparatorChar}; public static string FixFileName( string fileName ) { if ( string.IsNullOrEmpty( fileName ) ) return string.Empty; char[] resultFileName = fileName.ToCharArray(); int shift = 0; int length = resultFileName.Length; bool lastCharIsSeparator = false; for ( int i = 0; i + shift < length; ) { if ( resultFileName[i + shift] == PathSeparatorChar || resultFileName[i + shift] == AltPathSeparatorChar ) { if ( !lastCharIsSeparator ) { lastCharIsSeparator = true; resultFileName[i] = PathSeparatorChar; ++i; } else { ++shift; } } else { resultFileName[i] = resultFileName[i+shift]; ++i; lastCharIsSeparator = false; } } string result = new string( resultFileName, 0, length - shift ); return result; } static int GetHashCode( string s ) { int result = 0; foreach (char c in s) { result = 5 * result + (byte)c; Console.WriteLine("c: {0}, byte c: {1}, result: {2}", c, (byte)c, result); } return result; } public static void Main(string[] args) { string fileName = "Blitzkrieg_15.ACHIEV.xdb"; var chars = fileName.ToCharArray(); var fix_str = FixFileName(fileName); var res = fix_str.TrimStart( PathSeparatorChar ).ToLower(); string fileName_1 = "Blitzkrieg_20.ACHIEV.xdb"; var chars_1 = fileName_1.ToCharArray(); var fix_str1 = FixFileName(fileName_1); var res1 = fix_str1.TrimStart( PathSeparatorChar ).ToLower(); //Your code goes here //Console.WriteLine("tocA: {0}, tocA1: {1}", fix_str, fix_str1); Console.WriteLine("first file name: {0}, second file name: {1}", res, res1); Console.WriteLine("hash first: {0}, hash second: {1}", GetHashCode(res), GetHashCode(res1)); } } }
run
|
edit
|
history
|
help
0
Merge Sort
zero comp
saved
HourCouter
Random number between IF Values
pascal
Create Sealed Class Object
Programa_01_01_Declaracion_de_clases
SADXS
Palindrome String