No announcements
Found 2491067 threads
-
0 Votes
Cast Generic Type to Enum
Try this: Enum.GetValues(typeof(T)).Cast<T>().Select(x => new { Value = x, . . .Answered | 1 Replies | 1751 Views | Created by MDMoura - Friday, February 15, 2013 11:34 AM | Last reply by Viorel_ - Friday, February 15, 2013 12:34 PM -
2 Votes
Test<T>() how to know the type of T?
After this, you can constrain your generic method to only accept types that implement this interface, and in the method you no longer have to test the type; ...Answered | 9 Replies | 3722 Views | Created by Sergiu Dudnic - Friday, July 3, 2009 10:39 AM | Last reply by David Fulop - Friday, July 3, 2009 1:47 PM -
1 Votes
Discovering type of generic object and casting accordingly.
But I got to wondering what if the implementing type is a generic, and I don't know the type of <T>?Answered | 9 Replies | 3202 Views | Created by Ralf Thompson - Sunday, August 23, 2009 8:12 PM | Last reply by Michael Sun [MSFT] - Friday, August 28, 2009 10:38 AM -
0 Votes
Casting with concrete generic type and interfaces
David, Your solution seems to work, i'm now able to read and write the Value property even when I don't know the generic type.Answered | 18 Replies | 9081 Views | Created by Dutchdre - Wednesday, February 4, 2009 12:44 PM | Last reply by Dutchdre - Wednesday, February 4, 2009 10:22 PM -
5 Votes
Cast object at runtime by Type-object
In order for the compiler to do that, the source and destination types have to be known at compile time - otherwise there's no way to know what method to call to perform ...Answered | 10 Replies | 3378 Views | Created by Ryder101 - Tuesday, July 19, 2011 2:25 PM | Last reply by Tim Copenhaver - Tuesday, July 19, 2011 7:35 PM -
2 Votes
How understand (and cast) Generic Type is List
Hi all, I have a generic type coming from another class.Answered | 4 Replies | 6688 Views | Created by İlker Yüksel - Saturday, March 18, 2017 9:44 AM | Last reply by İlker Yüksel - Saturday, March 18, 2017 9:23 PM -
0 Votes
Cast object to IList<T>
According to the docs for the PersistentGenericBag class, the object in question is already an IList<Person>, so you would just need to cast ...Answered | 1 Replies | 4353 Views | Created by utkuozan - Tuesday, April 19, 2011 2:34 PM | Last reply by Evan Machusak - Tuesday, April 19, 2011 6:43 PM -
3 Votes
Unable to cast object of type 'iTextSharp.text.html.simpleparser.IncTable' to type 'iTextSharp.text.IElement'.
Just like Filip have mentioned, there isn’t an inheritance relationship between the two types.Answered | 3 Replies | 10551 Views | Created by Karthika Subramanian - Thursday, October 13, 2011 10:07 AM | Last reply by Dummy yoyo - Monday, October 17, 2011 8:44 AM -
0 Votes
casting from Generic collection class
Maybe the code sample was from a previous book edition, FCL 1.1, before generics was available.Answered | 6 Replies | 2919 Views | Created by Colonel de Bugger - Tuesday, October 21, 2008 2:44 PM | Last reply by Colonel de Bugger - Wednesday, October 22, 2008 9:57 AM -
0 Votes
Generically call List<T>.AddRange
To be able to use AddRange, list has to be a List<T> and newData has to implement IEnumerable<T>, so we have to check the types of both parameters.Answered | 4 Replies | 3611 Views | Created by Chris-von-der-Wiese - Thursday, August 8, 2013 9:26 PM | Last reply by mbj79 - Thursday, August 8, 2013 11:22 PM -
0 Votes
Casting object if Type known
The return is an object, you can cast it...but if you know the type of object being run, why not use that knowledge switch off of the string class name and then apply the as ...Answered | 2 Replies | 3004 Views | Created by midfieldgeneral - Monday, April 20, 2009 6:11 PM | Last reply by OmegaMan - Monday, April 20, 2009 7:49 PM -
1 Votes
How to typecast "Type" object to class without knowing its class
you can instead the type of T?Answered | 21 Replies | 2703 Views | Created by agarwal - Thursday, August 30, 2012 10:33 AM | Last reply by Patrice Scribe - Thursday, September 6, 2012 1:02 PM -
0 Votes
Difference between Boxing/Unboxing & Type Casting
Does anyone know how/why using generics is more efficient than boxing/unboxing?Answered | 9 Replies | 15691 Views | Created by Zeeshan Jan - Thursday, December 31, 2009 6:06 AM | Last reply by DA924x - Thursday, August 31, 2017 11:34 PM -
1 Votes
datatemplate for generic type is not working.
Also using object is not good because it demands casting.Answered | 9 Replies | 3489 Views | Created by Booster1 - Thursday, August 22, 2013 1:34 PM | Last reply by Magnus (MM8) - Friday, August 30, 2013 9:46 AM -
3 Votes
Static code down-cast vs. dynamic generic down-cast?
In above example I get what I want without explicitly use of the dynamic keyword.Answered | 12 Replies | 3798 Views | Created by KeldØlykke - Tuesday, June 18, 2013 3:37 PM | Last reply by KeldØlykke - Tuesday, June 18, 2013 11:24 PM -
0 Votes
Casting in Generics
type=forum&referrer=http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/114f70d5-edd6-4d3b-af6b-e482ba0cb07e?Answered | 3 Replies | 2240 Views | Created by DevCoder - Wednesday, September 15, 2010 4:51 PM | Last reply by Mike Dos Zhang - Tuesday, September 21, 2010 8:46 AM -
0 Votes
Using A Generic List<T> Return, Based On Collection Type
You can either create a common base class of your collection types or use the non-generic version of IList.Answered | 6 Replies | 24428 Views | Created by phpnuke23 - Friday, March 18, 2011 4:26 PM | Last reply by Aspen VJ - Monday, March 21, 2011 7:55 AM -
0 Votes
About type cast
Joy, A quick way to find the actual type of the object you get when you reach into the conversation property bag is to use reflection to do the ...Answered | 2 Replies | 2820 Views | Created by iwannaprogramlync - Friday, July 20, 2012 7:49 AM | Last reply by iwannaprogramlync - Monday, July 23, 2012 8:15 AM -
0 Votes
How to instantiate variable of Type T in generics
= null && obj.GetType().Equals(T.GetType())) value = (T)obj; return true; } Any fool can know.Answered | 9 Replies | 26455 Views | Created by mafab - Wednesday, September 28, 2011 1:38 PM | Last reply by Ehsan Mohammadi - Thursday, September 29, 2011 12:11 AM -
1 Votes
Type casting error
You could also use: if (list is SPDocumentLibrary) { SPDocumentLibrary lib = (SPDocumentLibrary)list; } which does the cast only if the list is ...Answered | 3 Replies | 5595 Views | Created by Sanjuo - Thursday, April 8, 2010 10:24 PM | Last reply by Sanjuo - Monday, April 12, 2010 3:46 PM - Items 1 to 20 of 2491067 Next ›
No announcements