Click here to Skip to main content
16,005,169 members
Home / Discussions / C#
   

C#

 
GeneralRe: Close form window Pin
Strategic_Thinker10-Feb-08 7:10
Strategic_Thinker10-Feb-08 7:10 
GeneralRe: Close form window Pin
Strategic_Thinker10-Feb-08 7:52
Strategic_Thinker10-Feb-08 7:52 
GeneralRe: Close form window Pin
Paul Conrad10-Feb-08 8:00
professionalPaul Conrad10-Feb-08 8:00 
GeneralRe: Close form window Pin
Strategic_Thinker10-Feb-08 8:57
Strategic_Thinker10-Feb-08 8:57 
GeneralRe: Close form window Pin
Eslam Afifi11-Feb-08 20:35
Eslam Afifi11-Feb-08 20:35 
GeneralRe: Close form window Pin
Anthony Mushrow10-Feb-08 5:21
professionalAnthony Mushrow10-Feb-08 5:21 
GeneralRe: Close form window Pin
Strategic_Thinker10-Feb-08 7:01
Strategic_Thinker10-Feb-08 7:01 
GeneralDinamic Return Type Pin
eterno.darknight10-Feb-08 0:29
eterno.darknight10-Feb-08 0:29 
I made a class which containt information of a database table.
Inside this class i have a list<> of another class which containt information about columns (colum name, value, type).
I need to use a property of this class which return the value of db column.
Is there a way to change return type of a property?

I put code for example:
class dbTable{
List<dbColumn> columns = new List<dbColumn>();

// sample function
public void GetSelectQuery(){
string sql = "";
foreach (dbColumn col in columns){
sql +=col.ColumnName + "=" + col.ColumnValue;
}
return sql;
}
}

class dbColumn{
private string pColumnName;
private object pColumnValue;
private Type pColumnType;

public string ColumnName{
get{
return pColumnName;
}
set{
pColumnName = value;
}
}
public object ColumnValue{
get{
return pColumnValue;
}
set{
pColumnValue = value;
}
}
public Type ColumnType{
get{
return pColumnType;
}
set{
pColumnType = value;
}
}

public dbColumn(string colName, object colValue, Type colType){
this.pColumnName = colName;
this.pColumnValue = colValue;
this.pColumnType = colType;
}
}

Using this code if I try to read value from a column I get an object, end every time I need to cast it to this specific value [for example (int) col.ColumnValue for an int value]

I also try other method:
1 - create different class which inherits from dbColumn [like dbColumnInt, dbColumnString... and so on] and using "new" attribute for ColumnValue i was able to override property in dbColumn class.
But this work if I use direct instance of on column, but in the sample function "GetSelectQuery()" I get null for col.ColumnValue [the solution is to analize col type and cast if, but it's like cast every time I use the column value in my code, so it's useless]
2 - using generic, create dbColumn<T> and return T with ColumnValue.
It may be the solution but i cannot create a collection on different dbColumn Type.

Someone as a solution for this?
GeneralRe: Dinamic Return Type Pin
Mark Churchill10-Feb-08 2:53
Mark Churchill10-Feb-08 2:53 
GeneralRe: Dinamic Return Type Pin
eterno.darknight10-Feb-08 3:37
eterno.darknight10-Feb-08 3:37 
GeneralRe: Dinamic Return Type Pin
Mark Churchill10-Feb-08 10:57
Mark Churchill10-Feb-08 10:57 
GeneralRe: Dinamic Return Type Pin
User 665810-Feb-08 6:28
User 665810-Feb-08 6:28 
GeneralRe: Dinamic Return Type Pin
eterno.darknight10-Feb-08 7:23
eterno.darknight10-Feb-08 7:23 
GeneralRe: Dinamic Return Type Pin
User 665810-Feb-08 8:08
User 665810-Feb-08 8:08 
GeneralRe: Dinamic Return Type Pin
eterno.darknight10-Feb-08 11:50
eterno.darknight10-Feb-08 11:50 
Questionis that warning true? Pin
Xmen Real 10-Feb-08 0:13
professional Xmen Real 10-Feb-08 0:13 
AnswerRe: is that warning true? Pin
Daniel Grunwald10-Feb-08 1:39
Daniel Grunwald10-Feb-08 1:39 
GeneralRe: is that warning true? [modified] Pin
Xmen Real 10-Feb-08 2:15
professional Xmen Real 10-Feb-08 2:15 
Generalsubmit articles Pin
Jimmy Zhang9-Feb-08 23:42
Jimmy Zhang9-Feb-08 23:42 
GeneralRe: submit articles Pin
bsaksida9-Feb-08 23:46
bsaksida9-Feb-08 23:46 
GeneralRe: submit articles Pin
Xmen Real 10-Feb-08 0:11
professional Xmen Real 10-Feb-08 0:11 
GeneralRe: submit articles Pin
Paul Conrad10-Feb-08 4:54
professionalPaul Conrad10-Feb-08 4:54 
GeneralSimple Data Biding Pin
bsaksida9-Feb-08 23:41
bsaksida9-Feb-08 23:41 
GeneralRe: Simple Data Biding Pin
bsaksida10-Feb-08 0:07
bsaksida10-Feb-08 0:07 
Generalsharepoint Pin
justintimberlake9-Feb-08 23:18
justintimberlake9-Feb-08 23:18 

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.