c# compare strings in different language -
i have strings in different languages; example:
- "kot jest dobry" (in polish)
- "cat good" (in english)
they captions of buttons translated english language chosen user.
which best way compare these captions, programmatically?
since both strings translations of 1 can maintain translation table , if want find out if 2 strings same can them in table , if happen fall in same row, equal example
class translatedtext { public int id {get; set; } public string language {get; set; } public string text {get; set; } } so populate list of translatedtext objects each string , assign same id same pieces of text. later compare can lookup corresponding object in list , check id so
var first = translatedtextlist.firstordefault(t=>t.text.equals(firststring)); var second = translatedtextlist.firstordefault(t=>t.text.equals(secondstring)); bool aresame = (first != null & second !=null & first.id == second.id); return aresame; assuming strings want compare called firststring , secondstring;
Comments
Post a Comment