Click here to Skip to main content
15,923,557 members
Home / Discussions / C#
   

C#

 
GeneralRe: help quick Pin
m@u19-Dec-07 4:45
m@u19-Dec-07 4:45 
GeneralRe: help quick Pin
Paul Conrad24-Dec-07 19:43
professionalPaul Conrad24-Dec-07 19:43 
GeneralProblems with PAINT program Pin
Luc Pattyn19-Dec-07 5:21
sitebuilderLuc Pattyn19-Dec-07 5:21 
GeneralSession Pin
anupamwb19-Dec-07 3:38
anupamwb19-Dec-07 3:38 
GeneralRe: Session Pin
DotNetXenon19-Dec-07 9:57
DotNetXenon19-Dec-07 9:57 
GeneralRe: Session Pin
anupamwb20-Dec-07 3:02
anupamwb20-Dec-07 3:02 
GeneralGenerics - How to implement Compare Methods Pin
gunner_uk200019-Dec-07 2:27
gunner_uk200019-Dec-07 2:27 
GeneralRe: Generics - How to implement Compare Methods Pin
OsoreWatashi19-Dec-07 2:52
OsoreWatashi19-Dec-07 2:52 
If you want to only have a list of possible items, then you should use a List.
Instead, if you want to have each item in a list to have some sort of reference number, a key, you should use a Dictionary.

The dictionary is located at System.Collections.Generic;

To make a Dictionary and use the basic functionality, see the following example:
<br />
public void myMethod()<br />
{<br />
    Dictionary<int, string=""> dict = new Dictionary<int, string="">();<br />
    dict.Add(1, "item1");<br />
    dict.Add(2, "item2");<br />
    <br />
    dict.ContainsKey(1); //Returns true<br />
    dict.ContainsKey(5); //Returns false<br />
    dict.ContainsValue("item1"); //Returns true<br />
    dict.ContainsValue("item5"); //Returns false<br />
    <br />
    string value = dict[1]; //Returns "item1"<br />
    string value = dict[2]; //Returns "item2"<br />
}<br />
</int,></int,>

Here it will add 2 values with each an own key. "item1" with the key 1, "item2" with the key 2. So if you for instance want to find the value that belongs to the key 1 (in your example Task.CompareID), you do string value = dict.[Taks.ComprareID].

Note here that you can use everything for the key and value, not only int and string. You are able to use objects. For objects it goes exact the same as with the int and string to find them: they have to be an exact match.
GeneralRe: Generics - How to implement Compare Methods Pin
LongRange.Shooter19-Dec-07 11:18
LongRange.Shooter19-Dec-07 11:18 
QuestionCapturing messeges from other program Pin
OsoreWatashi19-Dec-07 2:14
OsoreWatashi19-Dec-07 2:14 
AnswerRe: Capturing messeges from other program Pin
TJoe20-Dec-07 3:11
TJoe20-Dec-07 3:11 
GeneralRe: Capturing messeges from other program Pin
OsoreWatashi28-Dec-07 3:45
OsoreWatashi28-Dec-07 3:45 
General[Message Deleted] Pin
eyeseetee19-Dec-07 1:02
eyeseetee19-Dec-07 1:02 
GeneralRe: strange problem with stored procedure Pin
Pete O'Hanlon19-Dec-07 1:18
mvePete O'Hanlon19-Dec-07 1:18 
GeneralRe: Deleted Message Pin
Paul Conrad24-Dec-07 19:44
professionalPaul Conrad24-Dec-07 19:44 
QuestionC#:Doubt in event handler? Pin
kssknov19-Dec-07 0:14
kssknov19-Dec-07 0:14 
GeneralRe: C#:Doubt in event handler? Pin
Giorgi Dalakishvili19-Dec-07 0:25
mentorGiorgi Dalakishvili19-Dec-07 0:25 
GeneralRe: C#:Doubt in event handler? Pin
Xmen Real 19-Dec-07 3:41
professional Xmen Real 19-Dec-07 3:41 
GeneralEntering null values from ComboBox Pin
AndrusM18-Dec-07 23:57
AndrusM18-Dec-07 23:57 
QuestionC#: How to change the color of a disabled textbox? Pin
kssknov18-Dec-07 22:45
kssknov18-Dec-07 22:45 
GeneralRe: C#: How to change the color of a disabled textbox? Pin
Pete O'Hanlon18-Dec-07 23:02
mvePete O'Hanlon18-Dec-07 23:02 
GeneralRe: C#: How to change the color of a disabled textbox? Pin
kssknov19-Dec-07 0:12
kssknov19-Dec-07 0:12 
GeneralRe: C#: How to change the color of a disabled textbox? Pin
Paul Conrad24-Dec-07 19:47
professionalPaul Conrad24-Dec-07 19:47 
GeneralRe: C#: How to change the color of a disabled textbox? Pin
Pete O'Hanlon19-Dec-07 0:51
mvePete O'Hanlon19-Dec-07 0:51 
GeneralRe: C#: How to change the color of a disabled textbox? Pin
Kalvin @ Work19-Dec-07 3:17
Kalvin @ Work19-Dec-07 3:17 

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.