I really do believe that I’m not asking a good question, but I’m new newbie
When I’m programming for example I try to use the contain method for finding a value in the dictionary data type:
I cud do it in my mind by two way:
dict.Values.Contains(str)(however I had an error using it)
Each of those methods is going to return a boolean if the value is contained within the dictionary. You appear to be using a string variable to as the test, so it assumes the TValue type of the dictionary is a string. You would be using the methods in the following manner:
If you want to retrieve the actual lists that contain the value, then you could do so with the following code samples. I'm showing two versions: a query expression syntax version and a lambda version.
var query = from list in dictionary.Values
var lambdaQuery = dictionary.Values.Where(list => list.Contains("a"));
can you explain this more.
LINQ and extension methods are too much to explain in a single post. The short short version is that LINQ stands for language integrated query and it makes querying collections much easier while using familiar syntax if you are from a SQL background (if you choose to use query expression syntax). Extension methods are methods that are created that appear to add methods to classes but are really static methods in unrelated static classes that use a special parameter syntax that allows you to use the method on an instance of a given class. Example:
static class Foo
public static int MultiplyBy(this int x, int y)
return x * y;
int a = 14;
int b = a.MultiplyBy(2);