Horje
get key in dictionary c# Code Example
get key value from object c#
Type myType = myObject.GetType();
IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());

foreach (PropertyInfo prop in props)
{
    object propValue = prop.GetValue(myObject, null);

    // Do something with propValue
}
get key in dictionary c#
public static void Main()
{
    Dictionary<string, string> dict = new Dictionary<string, string>()
    {
        {"1", "one"},
        {"2", "two"},
        {"3", "three"}
    };

    string key = KeyByValue(dict, "two");       
    Console.WriteLine("Key: " + key);
}
get key in dictionary c#
public static string GetKeyFromValue(string valueVar)
{
   foreach (string keyVar in dictionaryVar.Keys) 
   { 
      if (dictionaryVar[keyVar] == valueVar)
      {
         return keyVar;
      }
   }
   return null;
}




Csharp

Related
convert-integer-to-binary-in-c-sharp Code Example convert-integer-to-binary-in-c-sharp Code Example
c# dynamic object get value Code Example c# dynamic object get value Code Example
The entity type has multiple properties with the [Key] attribute. Code Example The entity type has multiple properties with the [Key] attribute. Code Example
LINQ query on a DataTable C# Code Example LINQ query on a DataTable C# Code Example
c# .net core memory cache Code Example c# .net core memory cache Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10