Click here to Skip to main content
15,924,829 members
Home / Discussions / C#
   

C#

 
QuestionHow to invoke delegates from any C# class Pin
Maddie from Dartford18-Jan-07 0:21
Maddie from Dartford18-Jan-07 0:21 
QuestionHow to identify the changes in TextBox? Pin
Nothend18-Jan-07 0:08
Nothend18-Jan-07 0:08 
AnswerRe: How to identify the changes in TextBox? Pin
ChandruIT18-Jan-07 0:19
ChandruIT18-Jan-07 0:19 
GeneralRe: How to identify the changes in TextBox? Pin
Nothend18-Jan-07 0:44
Nothend18-Jan-07 0:44 
GeneralRe: How to identify the changes in TextBox? Pin
ShermansLagoon18-Jan-07 1:16
ShermansLagoon18-Jan-07 1:16 
GeneralRe: How to identify the changes in TextBox? Pin
Nothend18-Jan-07 1:52
Nothend18-Jan-07 1:52 
AnswerRe: How to identify the changes in TextBox? Pin
quiteSmart18-Jan-07 0:25
quiteSmart18-Jan-07 0:25 
QuestionProblems with Generic Collection class. Pin
burrows.stephen17-Jan-07 23:51
burrows.stephen17-Jan-07 23:51 
Hi I’m working on a system that has 4 different types of client they have mostly the same attributes so I decided to create an interface IClient for them to implement and then just add the differing attributes as needed to each client class.

Now I get the Client information from a DB and Load them into a Generic dictionary

The class looks like so
[code]
class Class1<T> : Dictionary<int, T> where T:IClient
{

private IndemnityScheme scheme;

public Class1(IndemnityScheme scheme)
{

this.scheme = scheme;


}

public int Load()
{

// "procIndemnityClientSelect";

DataBaseAccess dba = new DataBaseAccess(this.scheme);
SqlDataReader reader = dba.LoadData("procPrsymClientSelect");
SmartDataReader smartReader = new SmartDataReader(reader);


while (smartReader.Read()) {

AceClient newClient = new AceClient(this.scheme);

newClient.Clientshort = smartReader.GetString("Client Short Name");
newClient.Clientname = smartReader.GetString("Client Name");
newClient.Clientref = smartReader.GetInt32("client ref");
newClient.AddressLine1 = smartReader.GetString("Address Line 1");
newClient.AddressLine2 = smartReader.GetString("Address Line 2");
newClient.AddressLine3 = smartReader.GetString("Address Line 3");
newClient.AddressLine4 = smartReader.GetString("Address Line 4");
newClient.AddressLine5 = smartReader.GetString("Address Line 5");
newClient.AddressLine6 = smartReader.GetString("Address Line 6");
newClient.Telephone = smartReader.GetString("Telephone No");
newClient.PostCode = smartReader.GetString("post code");
newClient.Contact = smartReader.GetString("Contact");
// newClient.Handler = smartReader.GetString("Handler");
newClient.Joindate = smartReader.GetString("Join Date");
newClient.Leavingdate = smartReader.GetString("leaving Date");
newClient.Salutation = smartReader.GetString("salutation");
newClient.Email = smartReader.GetString("Email");
newClient.Comments = smartReader.GetString("comments");
base.Add(newClient.Clientref, newClient);


}
smartReader.Close();
smartReader = null;
dba = null;
return base.Count;



}


}
[/code]

I call the class in my program like so
[code]
AceClient c = new AceClient(IndemnityScheme.ACE);
Class1<AceClient> cl = new Class1<AceClient>(IndemnityScheme.ACE);
cl.Load();

foreach (AceClient ac in cl.Values) {
System.Diagnostics.Debug.WriteLine(ac.Clientshort);

}
[/code]
Nothing fancy just want to loop throught the collection but on trying to complie I get an error.


This is the line of code that errors
[code]
base.Add(newClient.Clientref, newClient);

[/code]
Error 24 The best overloaded method match for 'System.Collections.Generic.Dictionary<int,T>.Add(int, T)' has some invalid arguments

Error 25 Argument '2': cannot convert from 'Prsym.AceClient' to 'T'

Can anyone tell me what I am doing wrong??

AnswerRe: Problems with Generic Collection class. Pin
Pete O'Hanlon18-Jan-07 0:00
mvePete O'Hanlon18-Jan-07 0:00 
GeneralRe: Problems with Generic Collection class. Pin
burrows.stephen18-Jan-07 0:45
burrows.stephen18-Jan-07 0:45 
Questionusing class Pin
HieuLD17-Jan-07 23:37
HieuLD17-Jan-07 23:37 
AnswerRe: using class Pin
Christian Graus17-Jan-07 23:45
protectorChristian Graus17-Jan-07 23:45 
Questiondynamic create control Pin
cocoonwls17-Jan-07 23:21
cocoonwls17-Jan-07 23:21 
AnswerRe: dynamic create control Pin
Seishin#17-Jan-07 23:26
Seishin#17-Jan-07 23:26 
AnswerRe: dynamic create control Pin
amitrajput28418-Jan-07 1:16
amitrajput28418-Jan-07 1:16 
QuestionMemory not released Pin
Rick van Woudenberg17-Jan-07 23:20
Rick van Woudenberg17-Jan-07 23:20 
AnswerRe: Memory not released Pin
Christian Graus17-Jan-07 23:45
protectorChristian Graus17-Jan-07 23:45 
GeneralRe: Memory not released Pin
Rick van Woudenberg18-Jan-07 0:10
Rick van Woudenberg18-Jan-07 0:10 
GeneralRe: Memory not released Pin
Christian Graus18-Jan-07 1:33
protectorChristian Graus18-Jan-07 1:33 
GeneralRe: Memory not released Pin
Rick van Woudenberg18-Jan-07 2:41
Rick van Woudenberg18-Jan-07 2:41 
GeneralRe: Memory not released Pin
Scott Dorman18-Jan-07 4:21
professionalScott Dorman18-Jan-07 4:21 
GeneralRe: Memory not released Pin
S. Senthil Kumar18-Jan-07 5:39
S. Senthil Kumar18-Jan-07 5:39 
GeneralRe: Memory not released Pin
Scott Dorman18-Jan-07 6:58
professionalScott Dorman18-Jan-07 6:58 
GeneralRe: Memory not released Pin
S. Senthil Kumar18-Jan-07 7:08
S. Senthil Kumar18-Jan-07 7:08 
GeneralRe: Memory not released Pin
Scott Dorman18-Jan-07 7:09
professionalScott Dorman18-Jan-07 7:09 

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.