Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: Block webbrowser from accessing webpages in C# Pin
Oscar Andersson21-Aug-13 20:48
Oscar Andersson21-Aug-13 20:48 
GeneralRe: Block webbrowser from accessing webpages in C# Pin
Eddy Vluggen22-Aug-13 5:13
professionalEddy Vluggen22-Aug-13 5:13 
GeneralRe: Block webbrowser from accessing webpages in C# Pin
Oscar Andersson22-Aug-13 20:43
Oscar Andersson22-Aug-13 20:43 
GeneralRe: Block webbrowser from accessing webpages in C# Pin
Dave Kreskowiak22-Aug-13 6:21
mveDave Kreskowiak22-Aug-13 6:21 
AnswerRe: Block webbrowser from accessing webpages in C# Pin
Bernhard Hiller21-Aug-13 21:55
Bernhard Hiller21-Aug-13 21:55 
QuestionBluetooth Pairing Problem Win8 Pin
LearnTheCoding20-Aug-13 20:50
LearnTheCoding20-Aug-13 20:50 
QuestionCollection with unique key by property Pin
Elfin Darkglow20-Aug-13 17:51
Elfin Darkglow20-Aug-13 17:51 
AnswerRe: Collection with unique key by property Pin
BillWoodruff20-Aug-13 19:14
professionalBillWoodruff20-Aug-13 19:14 
If your collection has only two Properties in it, and you wish to make sure that one of those Properties is never a duplicate: you have an easy solution.

Create a Dictionary where the Property you don't want to allow duplicates of is the Key, and the other Property is the Value:
XML
private Dictionary<string, int> Pets = new Dictionary<string, int>();
To use this, somewhere in your code do something like this:
C#
Pets.Add("Ares", 3);
Pets.Add("Mike", 6);

// let's pull out a specific KeyValuePair
string keyToGet = "Ares";

var testKVP = Pets.FirstOrDefault(kvp => kvp.Key == keyToGet);

// if we didn't find that one, quit
if (testKVP.Key == null) return;

// proof #1: that you can't change Key
// testKVP.Key = "AnotherMike";
// fail:
// Property or indexer
// 'System.Collections.Generic.KeyValuePair<string,int>.Key'
// cannot be assigned to -- it is read only

// proof #2: that you can't create
// a new entry with the same Key
// Pets.Add("Ares", 9);
// fail:
// An item with the same key has already been added.


~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal

AnswerRe: Collection with unique key by property Pin
Bernhard Hiller20-Aug-13 21:12
Bernhard Hiller20-Aug-13 21:12 
QuestionHow To Add Buttons In Textbox? Pin
gaofq20-Aug-13 16:03
gaofq20-Aug-13 16:03 
AnswerRe: How To Add Buttons In Textbox? Pin
BillWoodruff20-Aug-13 18:13
professionalBillWoodruff20-Aug-13 18:13 
GeneralRe: How To Add Buttons In Textbox? Pin
gaofq21-Aug-13 4:43
gaofq21-Aug-13 4:43 
GeneralRe: How To Add Buttons In Textbox? Pin
Ravi Bhavnani21-Aug-13 7:38
professionalRavi Bhavnani21-Aug-13 7:38 
GeneralRe: How To Add Buttons In Textbox? Pin
BillWoodruff21-Aug-13 11:31
professionalBillWoodruff21-Aug-13 11:31 
GeneralRe: How To Add Buttons In Textbox? Pin
Ravi Bhavnani21-Aug-13 11:37
professionalRavi Bhavnani21-Aug-13 11:37 
GeneralRe: How To Add Buttons In Textbox? Pin
Mycroft Holmes21-Aug-13 12:53
professionalMycroft Holmes21-Aug-13 12:53 
QuestionTreeview node folder images Pin
rfresh20-Aug-13 13:28
rfresh20-Aug-13 13:28 
AnswerRe: Treeview node folder images Pin
BillWoodruff20-Aug-13 14:57
professionalBillWoodruff20-Aug-13 14:57 
GeneralRe: Treeview node folder images Pin
rfresh20-Aug-13 15:03
rfresh20-Aug-13 15:03 
GeneralRe: Treeview node folder images Pin
BillWoodruff20-Aug-13 15:13
professionalBillWoodruff20-Aug-13 15:13 
GeneralRe: Treeview node folder images Pin
rfresh20-Aug-13 18:09
rfresh20-Aug-13 18:09 
GeneralRe: Treeview node folder images Pin
BillWoodruff21-Aug-13 2:01
professionalBillWoodruff21-Aug-13 2:01 
AnswerRe: Treeview node folder images Pin
Ravi Bhavnani21-Aug-13 7:40
professionalRavi Bhavnani21-Aug-13 7:40 
AnswerRe: Treeview node folder images Pin
SaqibRasheed23-Aug-13 2:19
SaqibRasheed23-Aug-13 2:19 
QuestionChart ToolTip using #VALX as Key of a dictionary Pin
PozzaVecia20-Aug-13 11:43
PozzaVecia20-Aug-13 11:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.