2016-04-12 17 views
0

私はそれらの2つの文字列を比較する必要がありますが、私はどのように考えているのかわかりません。私はウェブで見つけたものすべてを試しましたが、何もできません。2つの文字列を比較する

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace Aufgabe_3_2 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string[,] zeichenSatz = new string[,] { {" ","0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"},   //creates a string array 
                { "0010","SP","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/"}, 
                { "0011","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?"}, 
                { "0100","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O"}, 
                { "0101","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_"}, 
                { "0110","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"}, 
                { "0111","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~",""}, 
                { "1010","NBSP","¡­","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","SHY","®","¯"}, 
                { "1011","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿"}, 
                { "1100","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï"}, 
                { "1101","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß"}, 
                { "1110","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï"}, 
                { "1111","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"}}; 

      Console.WriteLine("Bitte geben sie ihren Text ein: ");     //request a input from user 
      string strText = Console.ReadLine(); 
      string[] strEingabe;         //makes other stuff 
      strEingabe = strText.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries); 
      string[] tempArray = new string[strText.Length]; 
      Console.WriteLine(strEingabe); 
      Console.WriteLine(strText); 
      Console.WriteLine(strText.Length); 
      Console.Write("0100||"); 

      for (int h = 0; h < strText.Length; h++) 
      { 
       for (int i = 0; i < zeichenSatz.GetLength(0); i++) 
       { 
        for (int j = 0; j < zeichenSatz.GetLength(1); j++) 
        { 
         if (strText[h].Equals(zeichenSatz[i, j]) == true) 
         { 
          Console.WriteLine("{0} , {1}", zeichenSatz[i, 0], zeichenSatz[0, j]); 
          Console.WriteLine(zeichenSatz[0, j]); 
          Console.WriteLine(" "); 
          } 
         } 
        } 
       } 
       Console.WriteLine("0000"); 
       Console.ReadLine(); 
       } 
      } 
     } 
+0

結果には何が必要ですか? – Vladimir

+0

テスト入力、期待される出力、アプリケーションが実際に出力する出力を提供してください。 – Corak

答えて

0

私はIEnumerableを拡張しました。我々の場合には

は、我々は、コレクションAのすべてのアイテムがコレクションBにある場合、それはあなたが欲しいものだ場合、私は知らない、同じ順序でnecessarly、いないかを知りたい:

public static bool ContentEquals<T>(this IEnumerable<T> enumerable, IEnumerable<T> other) 
    { 
     if (Equals(enumerable, other)) 
     { 
      return true; 
     } 

     if (enumerable == null || other == null) 
     { 
      return false; 
     } 

     if (enumerable.Count() != other.Count() || enumerable.Except(other).Any()) 
     { 
      return false; 
     } 

     foreach (T value in enumerable.Distinct()) 
     { 
      if (enumerable.Count(v => Equals(v, value)) != other.Count(v => Equals(v, value))) 
      { 
       return false; 
      } 
     } 

     return true; 
    } 

用法:あなたのケースでは

if(listOne.ContentEquals(listTwo)){ 
    ... 
} 

、私はあなたが行うことができますね。zeichenSatz[0].ContentEquals(zeichenSatz[1]);

0

あなたはLINQを使用することができます:

bool areEqual = a.SequenceEqual(b);