So i was going to try out diffrent ways to implement search algorithms... but instead to just do that, i got the idea!
To remind me self how generics works and learn more about the subject.
Did this:
using System;
namespace linearysearch
{
static class Search
{
static public void Linear(T[] store, T Key)
{
for (int i = 0; i < store.Length; i++)
{
if (store[i] == Key)
{
Console.WriteLine("\tQQQQ you where searching for was: {0} \n\tand was found in element: {1}.", Key, i);
}
}
}
}
class Program
{
static void Main(string[] args)
{
int Key = 2;
int[] store = new int[] { 9, 8, 1, 99, 33, 2 };
Search.Linear<int>(store, Key);
//string Key = "tomas";
//string[] store = new string[] { "adam", "tomas", "erika", "greger" };
//Search.Linear<string, string>(store, Key);
}
}
}
And got stucked, search the internets! Found this thread:
That explain why it dosent work, i think(having some problems understanding it), but i cant come up with a solution for my problem. Thats why iam here, hope some one can help me out!
And one more thing, is it possible to make the "store" array name generic too. Thats was my next problem...
Best regards Tomas!
PS Sorry for my bad english, working on that too! :D