Click here to Skip to main content
15,919,774 members
Home / Discussions / C#
   

C#

 
AnswerRe: Calendar will not show highlighted day Pin
leppie3-Dec-08 10:24
leppie3-Dec-08 10:24 
QuestionComponent To Select Multiple Folders Pin
Michael Fritzius3-Dec-08 9:49
professionalMichael Fritzius3-Dec-08 9:49 
AnswerRe: Component To Select Multiple Folders Pin
Christian Graus3-Dec-08 9:50
protectorChristian Graus3-Dec-08 9:50 
GeneralRe: Component To Select Multiple Folders Pin
Michael Fritzius3-Dec-08 9:56
professionalMichael Fritzius3-Dec-08 9:56 
AnswerRe: Component To Select Multiple Folders Pin
Wendelius3-Dec-08 10:57
mentorWendelius3-Dec-08 10:57 
GeneralRe: Component To Select Multiple Folders Pin
Michael Fritzius5-Dec-08 2:32
professionalMichael Fritzius5-Dec-08 2:32 
GeneralRe: Component To Select Multiple Folders Pin
Wendelius5-Dec-08 8:19
mentorWendelius5-Dec-08 8:19 
QuestionHow to convert dynamicaly an array of one type to an array of another type Pin
User 43300283-Dec-08 7:57
User 43300283-Dec-08 7:57 
Hi, i want to convert arrys of one type to arrays of another type
Here is the code that i have
public object ConvertTo(Type myType, object value) {
     // code...
     // value is an array
     object[] ret = Array.ConvertAll(value as object[], delegate(object o) { return Convert.ChangeType(o, t.GetElementType()); });
     return ret;
}


Everithing its just fine, but the problem using Array.ConvertAll is that I have an object[] reference, an not an t.GetElementType()[] reference

So, when i use the variable returned by that function, i have an InvalidCastException because object[] cannot be converted to myType[]

How can i make a cast to the type i really want?

The next code works perfectly, but i want it to work with a generic type

public object ConvertToStringArray(object value) {
     // code...
     // value is an array of anything
     string[] ret = (string[])Array.ConvertAll(value as object[], delegate(object o) { return o.ToString(); });
     return ret;
}



Maybe the question is how to create an array of a type represented by an instance of System.Type
Example:
Type t = typeof(System.String);
// create an array of t? like string[] ?


Saludos!!

____Juan

AnswerRe: How to convert dynamicaly an array of one type to an array of another type Pin
Christian Graus3-Dec-08 9:07
protectorChristian Graus3-Dec-08 9:07 
GeneralRe: How to convert dynamicaly an array of one type to an array of another type Pin
User 66583-Dec-08 9:48
User 66583-Dec-08 9:48 
GeneralRe: How to convert dynamicaly an array of one type to an array of another type Pin
Christian Graus3-Dec-08 9:50
protectorChristian Graus3-Dec-08 9:50 
GeneralRe: How to convert dynamicaly an array of one type to an array of another type Pin
User 43300283-Dec-08 14:21
User 43300283-Dec-08 14:21 
QuestionPDF Viewer for Win Form App using C# Pin
Karmendra Suthar3-Dec-08 7:47
Karmendra Suthar3-Dec-08 7:47 
AnswerRe: PDF Viewer for Win Form App using C# Pin
Wendelius3-Dec-08 8:20
mentorWendelius3-Dec-08 8:20 
GeneralRe: PDF Viewer for Win Form App using C# Pin
Karmendra Suthar3-Dec-08 8:26
Karmendra Suthar3-Dec-08 8:26 
GeneralRe: PDF Viewer for Win Form App using C# Pin
Wendelius3-Dec-08 8:37
mentorWendelius3-Dec-08 8:37 
QuestionVS2008 / Northwind dataset problem Pin
mhrtg3-Dec-08 7:15
mhrtg3-Dec-08 7:15 
AnswerRe: VS2008 / Northwind dataset problem Pin
Wendelius3-Dec-08 8:17
mentorWendelius3-Dec-08 8:17 
GeneralRe: VS2008 / Northwind dataset problem Pin
mhrtg3-Dec-08 9:24
mhrtg3-Dec-08 9:24 
GeneralRe: VS2008 / Northwind dataset problem Pin
Wendelius3-Dec-08 10:04
mentorWendelius3-Dec-08 10:04 
GeneralRe: VS2008 / Northwind dataset problem Pin
mhrtg4-Dec-08 4:26
mhrtg4-Dec-08 4:26 
QuestionAbout PrintPreview Problem?-Plz respond about my query [modified] Pin
Roney3-Dec-08 5:59
Roney3-Dec-08 5:59 
QuestionReport Progress from a method being executed within a background worker. Pin
Matthew Edmondson3-Dec-08 5:53
Matthew Edmondson3-Dec-08 5:53 
AnswerRe: Report Progress from a method being executed within a background worker. Pin
Mark Salsbery3-Dec-08 6:15
Mark Salsbery3-Dec-08 6:15 
GeneralRe: Report Progress from a method being executed within a background worker. Pin
Luc Pattyn3-Dec-08 6:49
sitebuilderLuc Pattyn3-Dec-08 6:49 

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.