casting

Cast has killed me - ????

Error 4 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<CCE_2009.Data.Person>>' to 'System.Collections.Generic.IEnumerable<CCE_2009.Data.Person>' Generated from: var RecoveryManagerQuery = from RM in ( from REP in e.Results select REP.Organ...

How to use Class.cast() properly?

Hey all, I have a Command class like the following: public class Command { ... private String commandName; private Object[] commandArgs; ... public void executeCommand() {} } I also have a subclass of Command, AuthenticateCommand: public class AuthenticateCommand extends Command { ... @Override public...

Simple c++ pointer casting

Can someone explain this to me: char* a; unsigned char* b; b = a; // error: invalid conversion from ‘char*’ to ‘unsigned char*’ b = static_cast<unsigned char*>(a); // error: invalid static_cast from type ‘char*’ to type ‘unsigned char*’ b = static_cast<unsigned char*>(static_cast<void*>(a)); // everything is fine What makes the dif...

Cast Integer to Boolean in Informix

I need to design my schema in Informix such that querying a BOOLEAN with an INTEGER type will work. e.g. SELECT id FROM mytable WHERE isavailable = ? works if I provide either a boolean False or an integer 0. I know I need to set up the schema with some kind of cast, but I'm not sure how. The reason for doing this is a bug in another par...

Is there a way to avoid @SuppressWarnings in this code?

Is there a way to avoid using @SuppressWarnings below and to keep the same functionality without the warning 'Type safety: Unchecked cast from AbstractDO[] to E[]': public MyClass { ... private Map<Class<? extends AbstractDO>, AbstractDO[]> map; ... private void saveConcreteDOs(AbstractDO[] theEntities) { entityMap.p...

How to cast System.Object[*] to System.Object[]

When I Tried to return a Array in VFP9 languaje COM/DLL to my .net c# project I received a System.Object[*] array and I can not cast to System.Object[] (Without asterisk). ...

how to implement casting to a private base class in C++

How to implement casting to a private base class in C++? I don't want to use hacks such as adding a friend etc. Defining public casting operator does not work. EDIT : For example I have: class A { //base class } class AX : private A { //a child } class AY : private A { //another specialized child } class B { //base class void do (A...

What is the difference between ((IEnumerable)source).OfType<T>() and source as IEnumerable<T>

What is the difference between ((IEnumerable)source).OfType<T>() and source as IEnumerable<T> For me they look similar, but they are not! source is of type IEnumerable<T>, but it is boxed as an object. Edit Here is some Code: public class PagedList<T> : List<T>, IPagedList { public PagedList(object source, int index, int pageSiz...

objectCast Sideways casting

I'm trying to replace all dynamicCasts in my code with QT's objectCast. But I've run into a bit of a snag. Here's the hierarchy of my objects: class ABase : public QObject class IAbility; // Registered as Qt Interface class ISize; // Registered as Qt Interface class Derived : public ABase, public IAbility, public ISize; // Uses Q_INTE...

C++ cannot convert from base A to derived type B via virtual base A

I have three classes: class A {}; class B : virtual public A {}; class C : virtual public A {}; class D: public B, public C {}; Attempting a static cast from A* to B* I get the below error: cannot convert from base A to derived type B via virtual base A ...

What actually happens when an integer is cast to a char pointer?

int i=40; char *p; p=(char *)&i;//What actually happens here? printf("%d",*p); What will be the output? Please help! ...

Qt Drag&Drop with own widgets?

I created a little widget on my own, including a QProgressBar and a QLabel in a QVBoxLayout. It has also a function which returns the text of the label (self-created). Now in my MainWindow I have two other QHBoxLayouts and I want to drag and drop my widget from one to another. It also works when I click on the little free space between t...

How to convert the column in order by linq

Select Year From MyTable Order By Cast( [Year] as Int ) Desc Same thing I am trying to do in the linq order by. It's not working. I have column that is defined in the data base as string (Varchar) and I need to cast/convert it to integer before I need to sort it. What should be my linq statement? Thanks in advance. ...

Casting void *user_data to object

how do I cast void *something to an object in standard C++? Specifically I want want to cast void *userdata to std::map<String, void*> Is this possible? I am trying: //void *user_data is a parameter of this function (callback) std::map <String, void*> user_data_n; //this line is ok user_data_n = static_cast<std::map<String, void *>>(*u...

EXEC_BAD_ADDRESS

Hi, maybe this is the continuation of this thread, The program compiles without errors or warnings but when I run it, and the handler function is called, I get EXEC_BAD_ADDRESS void MainController::show_color_trackbars(int *h, int *s, int *v){ String winName = "HSV Trackbars"; namedWindow(winName, CV_WINDOW_AUTOSIZE); std:...

Cannot cast Exception to ArgumentException?

ArgumentException argumentException = (ArgumentException)new Exception(); throws: System.InvalidCastException: Unable to cast object of type 'System.Exception' to type 'System.ArgumentException'. Why can I not cast an Exception (less definition, I would think) to an ArgumentException (more definition, I would think)? ...

2 objects, exactly the same (except namespace) c#

I'm using a 3rd party's set of webservices, and I've hit a small snag. Before I manually make a method copying each property from the source to the destination, I thought I'd ask here for a better solution. I've got 2 objects, one of type Customer.CustomerParty and one of type Appointment.CustomerParty. The CustomerParty objects are a...

Convert boolean to int in Java

What is the most accepted way to convert a boolean to an int in Java? ...

Java: Casting from List<B> to List<A> when B implements A?

I have the following class & interface defined: public interface A { } public class B implements A { } I have a List of B objects that I need to cast to a List of A objects: List<B> listB = new List<B>(); listB.add(new B()); // dummy data listB.add(new B()); // dummy data listB.add(new B()); // dummy data List<A> listA = (List<A>...

Casting subclasses extending the same original class

How can I cast two extends class like that in java? class B extends Object{ } class C extends Object{ } B b = new B(); C c = (C)b;//Cannot cast from B to C ...