casting

Cast a variable to a Type and call Methods

旧巷老猫 提交于 2019-12-24 16:28:43
问题 How would I go about invoking a method call for an Object after casting it to a Type? I have a KeyValuePair which stores the type of the object and the object itself. I then want to cast this object to its key type and invoke a method of that class type. KeyValuePair<Type, Object> client = myClients.Find( delegate(KeyValuePair<Type, Object> result) { return (result.Key == myClients[clientNumber].Key); // Match client of the same type } ); if (client.Value != null) { // cast client.Value to

C++ reinterpret_cast - will this always work correctly?

有些话、适合烂在心里 提交于 2019-12-24 16:27:36
问题 I have written MyString and MyStringConst class. Now I need from time to time pass MyString as MyStringConst, hence overload cast operator. I have written this MyString::operator const MyStringConst &() const { return reinterpret_cast<const MyStringConst &>(*this); } MyString has this data char * str; int length; volatile int hashCode; int bufferSize; MyStringConst has this data const char * c_str; int length; volatile int hashCode; Plus there are some methods, that in both strings can

MS SQL Server: cast double to string and compare text

自作多情 提交于 2019-12-24 15:53:51
问题 In MS SQL Server I have a filed of type double that is called ID , and that stores ID numbers, surprisingly enough. Anyway, I want to be able to search ID numberss like text - say I want all ID's that starts with 021 or that ends with 04 - to do so I need to convert the double the string. My problem is that ID numbers here are 9 digits, so when I try SELECT str([id]) I get something like 02123+e23 , which is not good for my purpose. How do I go about converting it to a string that looks

Assign ajax result to interface inclusive methods

混江龙づ霸主 提交于 2019-12-24 15:37:01
问题 I'm quite new to Typescript and have a bit of a problem to get my code working. I have the following interface/class structure interface IInterface { id : number; method() : string; } class IClass implements IInterface { id : number; method() : string { return "foo";} } Now I want to get some data from a webservice via the following call $.get("/some/url", (data : Array<IInterface>) => { for (var i = 0; i < data.length; i++) { console.log(data[i].id); console.log(data[i].method()); } });

Trouble Casting COM Object to a C#/.NET Class

落爺英雄遲暮 提交于 2019-12-24 14:44:13
问题 I have a base class that is written in C# that implements an interface defined in an IDL library. I have a C++ class that manages the single instance of this class. I also have a C# project that needs to make use of this class [instance (that is obtained through the C++ project)]. I want to cast the COM interface that my base class implements back into my C# base class. However, when I cast the generic object that I acquired from the C++ proportion into my C# base class, I received an error.

Trouble Casting COM Object to a C#/.NET Class

风流意气都作罢 提交于 2019-12-24 14:31:50
问题 I have a base class that is written in C# that implements an interface defined in an IDL library. I have a C++ class that manages the single instance of this class. I also have a C# project that needs to make use of this class [instance (that is obtained through the C++ project)]. I want to cast the COM interface that my base class implements back into my C# base class. However, when I cast the generic object that I acquired from the C++ proportion into my C# base class, I received an error.

How to properly connect to Google Cast device and cast an url with an custom receiver?

跟風遠走 提交于 2019-12-24 14:23:02
问题 For creating this I used Google Cast reference at Github https://github.com/googlecast/CastHelloText-ios & https://github.com/googlecast/CastVideos-ios Then if you downloaded it have a look at my block of code that has to do with Google Cast. If you see something that makes this error happen, please let me know. Because I honestly don't know if this a Xcode or a Google Cast bug.. or is the most common error.. Humans Start the emulator, it wil look for active Chrome Cast devices in the network

Casting to String or using String.valueOf() in Java [duplicate]

Deadly 提交于 2019-12-24 13:24:15
问题 This question already has answers here : Difference between casting to String and String.valueOf (8 answers) Closed 6 years ago . This morning I found an interesting question --- cast object to string check if valid and I found there are two types of answers. One is to cast an object to String, the other one is to get the string representation of that object instead (eg. using String.valueOf() or toString()). My questions are: what is the best practice? what is the difference between them?

Safe Dynamic JSON Casts In Swift

独自空忆成欢 提交于 2019-12-24 13:12:17
问题 I suspect that I am not quite grokking Swift 1.2, and I need to RTFM a bit more. I'm working on a Swift app that reads JSON data from a URI. If the JSON data is bad, or nonexistent, no issue. The JSON object never instantiates. However, if the JSON data is good JSON, but not what I want, the object instantiates, but contains a structure that is not what I'm looking for, I get a runtime error. I looked at using Swift's "RTTI" (dynamicType), but that always returns "<Swift.AnyObject>", no

R: How to create matrix in a loop using cast-function?

混江龙づ霸主 提交于 2019-12-24 12:44:32
问题 I try to make a yearly country import matrix out of a yearly list using the cast function in the reshape-package . As I try this for a single year everything works fine. See code (test-dataset below!) : OCTC2011 <- cast(OC ~ TC, data =Import_Year[["2011"]], value = "Value") The result is a matrix containing the import-values of the year 2011 from the origin-country (OC) (rows) to the target-country (TC) (columns). However, as I use a large dataset consisting of different products for