Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.
mr-ponna.com

 

YOU ARE HERE: HOME Questions Write a code to find the string in 2 dimentional array



Code to find the string in two dimentional array

View(s): 20763

Write a code to find the string in 2 dimentional array

Answer 1)

static void Main(string[] args)
{
string[][] textArray = new string[][] { new string[] { "apple", "bat" }, new string[] { "cat", "dog" } };
string foundKey = Search(textArray, "bat");
Console.WriteLine(string.Format("found: {0}", foundKey));
}

static string Search(string[][] strDoubleDimArray, string searchKey)
{
string foundStr = null;
foreach (string[] eachStrSingleDimArray in strDoubleDimArray)
{
  foundStr =
Array.Find(eachStrSingleDimArray, eachElement => eachElement.Equals(searchKey, StringComparison.CurrentCultureIgnoreCase));

  if (!string.IsNullOrEmpty(foundStr))
     break;
}

return foundStr;
}

  Asked in:  SemanticSpace Technologies   Expertise Level:  Beginner
  Last updated on Thursday, 02 June 2011
3/5 stars (12 vote(s))

Register Login Ask Us Write to Us Help