cast

LINQ: concatenate multiple int properties into a string

I have an object with two different integer properties in it, and I'm trying to get a a new object in Linq to Entities, combining two integer properties from the same object as concatenated strings, as follows List<DateRange> collection = (from d in context.dates select new DateRange { DateString = from s in context.Seasons wher...

Melting a cast data frame gives incorrect output (Hadley Wickham's reshape package in R)

I've encountered a strange behaviour in cast/melt from Hadley Wickham's reshape package. If I cast a data frame, and then try to melt it, the melt comes out wrong. Manually unsetting the "df.melt" class from the cast dataframe lets it be melted properly. Does anyone know if this is intended behaviour, and if so, what is the use case whe...

multiple inheritance: unexpected result after cast from void * to 2nd base class

My program needs to make use of void* in order to transport data or objects in dynamic invocation situation, so that it can reference data of arbitrary types, even primitive types. However, I recently discovered that the process of down-casting these void* in case of classes with multiple base classes fails and even crashes my program af...

how to open multiple projects into the CAST IRON integration tool?

Hi, I am learning the cast iron tool (http://www.castiron.com/) which is widely used now a days for integration purpose,but i can only open 1 project and if i want to open the other project at the same time than i have to close the 1st project and open the 2nd project. So many times i need to have to open the 2 projects at the same tim...

C# cast audio form resources

i need some help regarding the following: HomeArrayPicBox[i, j].Image = (Image)Properties.Resources.ResourceManager.GetObject("Scan" + i); SoundPlayer fire = new SoundPlayer(Properties.Resources.fire); for the picbox i can load an image from resources using cast (Image). i was wondering how to do this for audio i.e. some sort of (Au...

Declare float or cast float?

Hey I've started to learn c++ using "C++ Primer by Stephen Prate" and I'm currently trying to complete one of the exercises. I am wondering if I should declare arc_to_minute & arc_to_degree as float or cast them as float as I've done already. Any tips welcome! #include <iostream> int main() { using namespace std; cout.setf(ios...

Casting to specific asp.net page type

I have an asp.net page with a code-behind class definition as follows: public partial class examplepage : System.Web.UI.Page I'd like to set a public property within the page that I can reference from other classes. My understanding is that if I cast to examplepage then I should be able to get at the public property that is specific ...

How can avoid at this line an OverflowException?

LastInput.time is an Integer and m_idleTime is an Integer too. This line sometimes generates an Overflow exception, I think that this happens when both values are big negative values. (Environment.TickCount - lastInput.time) > m_idleTime How can I avoid that? With casting? (CType(Environment.TickCount,Long) - CType(lastInput.time,Lon...

Covert from "TimeSpan" to "Long"

Hey guys how can I convert a "timespan" datatype to "long"? cheers psilos ...

Java HashSet<Integer> to int array

I've got a HashSet with a bunch of (you guessed it) integers in it. I want to turn it into an array, but calling hashset.toArray(); returns an array of Object type. This is fine, but is there a better way to cast it to an array of int, other than iterating through every element manually? A method I want to pass it to void doSomething...

Doesn't the Visual Studio 2008 compiler autocast to double with sqrt in C++?

Shouldn't the compiler automatically cast to a double in the following? At least according to Walter Savitch. #include <iostream> #include <cmath> using namespace std; int main(){ int k; for(k = 1; k <= 10; k++) cout << "The square root of k is: " << sqrt(k) << endl; return 0; }//error C2668: 'sqrt' : ambiguous call...

How are integers casted to bytes in Java?

I know Java doesn't allow unsigned types, so I was wondering how it casts an integer to a byte. Say I have an integer a with a value of 255 and I cast the integer to a byte. Is the value represented in the byte 11111111? In other words, is the value treated more as a signed 8 bit integer, or does it just directly copy the last 8 bits of ...

Convert int64_t to NSInteger

Hi all, How can i convert int64_t to NSInteger in Objective-C ? This method returns into score an int64_t* and I need to convert it to NSInteger: [OFHighScoreService getPreviousHighScoreLocal:score forLeaderboard:leaderboardId]; Thank you. ...

Casting array of pointers to objects

If B is subclass of A. And I have in main(): B** b = new B*[10]; ... // some algorithm that does b[i] = new B(..); So I have an array of pointers to objects B. Then I have a function: void f(A** foo); If in main, I do: f(b); I get a warning, but obviously if I do: f((A**)b);, I don't. The (A**) its a bit nasty. I was wondering i...

How can I instantiate a base class and then convert it to a derived class?

I was wondering how to do this, consider the following classes public class Fruit { public string Name { get; set; } public Color Color { get; set; } } public class Apple : Fruit { public Apple() { } } How can I instantiate a new fruit but upcast to Apple, is there a way to instantiate a bunch of Fruit and make th...

SQL cast datetime

In SQL Server 2005, why does: PRINT Cast('' AS datetime) display: Jan 1 1900 12:00AM I would have thought it should be null? ...

Convert varchar to numeric in Informix

I have problem while converting varchar type to Int type in Informix. Actually I don't know if the value is really varchar or not which I want to convert to INT. It's a sandbox system. As Example: I am trying to run this kind of Select telnumber from numbers n where Cast(n.telnumber AS INT) between 1234 and 9999 I got this error:...

C# Reflection - Casting private Object field

I have the following classes: public class MyEventArgs : EventArgs { public object State; public MyEventArgs (object state) { this.State = state; } } public class MyClass { // ... public List<string> ErrorMessages { get { return errorMessages; } ...

Explanation of casting/conversion int/double in C#

I coded some calculation stuff (I copied below a really simplifed example of what I did) like CASE2 and got bad results. Refactored the code like CASE1 and worked fine. I know there is an implicit cast in CASE 2, but not sure of the full reason. Any one could explain me what´s exactly happening below? //CASE 1, result 5.5 double a...

Integer to byte conversion

Say I've got an integer, 13941412, that I wish to separate into bytes (the number is actually a color in the form 0x00bbggrr). How would you do that? In c, you'd cast the number to a BYTE and then shift the bits. How do you cast to byte in Python? ...