C# Dictionary class represent the key
and pair values . set of pair values like key is a course means amount is a
pair values.
Dictionary<string, int>;
Display Dictionary key and value <string,int> using KeyValuePair
Code
Dictionary<string, int> value = new Dictionary<string, int>();
value.Add("Asp.Net",5999);
value.Add("C#", 7999);
value.Add("JavaScript", 7666);
foreach(KeyValuePair<string,int> val in value)
{
Response.Write(string.Format("{0},{1}",val.Key,val.Value)+"<br>");
}
Code
Display Dictionary Key only <string,int> using KeyValuePair
Dictionary<string, int> value = new Dictionary<string, int>();
value.Add("Asp.Net",5999);
value.Add("C#", 7999);
value.Add("Jquery", 8999);
value.Add("JavaScript", 7666);
value.Add("VB.NET", 6999);
foreach(KeyValuePair<string,int> val in value)
{
Response.Write(string.Format("{0}",val.Key+"<br>"));
Code
Display Dictionary value <string,int> using KeyValuePair
Dictionary<string, int> value = new Dictionary<string, int>();
value.Add("Asp.Net",5999);
value.Add("C#", 7999);
value.Add("Jquery", 8999);
value.Add("JavaScript", 7666);
value.Add("VB.NET", 6999);
{
Response.Write(string.Format("{0}",val.Value+"<br>"));
}
Code
Dictionary<string, int> value = new Dictionary<string, int>();
value.Add("Asp.Net",5999);
value.Add("C#", 7999);
value.Add("Jquery", 8999);
value.Add("JavaScript", 7666);
value.Add("VB.NET", 6999);
if (value.ContainsKey("1000")
== true)
{
Response.Write("YES");
}
else
{
Response.Write("NO");
0 comments:
Post a Comment