I tend to use ArrayLists of structures. It is then very easy to cycle through the list with a foreach.
The problem I have is I cant use a foreach to modify the structures contents and have to use a for and messy typecasts.
((dataStructure)files[x]).name = here;
Is there a tidier way to do it?
...
Can someone tell me why when I cast a string of say 00332 I only get back 332? It removes the leading zeros and saves the data in the same format.
Thanks
this->_gate = (string) $this->_linkID->QuoteSmart($gate);
...
Hi
I'm newish to flex an have recently hit a snag casting.
this is the code I'm running.
/**
* return background definition depending on time
*/
private function findBackgroundItem( relativeTime : Number ) : CSBackgroundItem
{
if( this.backgroundItems == null ) return null;
var result :CSBackgroundItem = null;
var relativ...
I recently ran into an issue where a query was causing a full table scan, and it came down to a column had a different definition that I thought, it was a VARCHAR not an INT. When queried with "string_column = 17" the query ran, it just couldn't use the index. That really threw me for a loop.
So I went searching and found what happened,...
Well, I have a class Customer (no base class).
I need to cast from LinkedList to List. Is there any clean way to do this?
Just so you know, I need to cast it to List. No other type will do. (I'm developing a test fixture using Slim and FitNesse).
EDIT: Okay, I think I need to give code examples here.
import java.util.*;
public clas...
Hi,
I've got a list of strings, is it possible to convert it to an list of ints?
eg:
["1","2"] -> [1,2]
THANKS,
...
I want a nice way to get the current unix timestamp from a java Date object, this is my solution:
public class Date extends java.util.Date {
public int getUnixTimeStamp() {
int unixtimestamp = (int) (this.getTime() * .001);
return unixtimestamp;
}
}
That works fine, but the problem is when I try to cast a java...
I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following:
A * getAnObject()
{
if(someBoolean)
return (A *) new B;
else
return (A *) new C;
}
Where "A" is the parent of classes "B" and "C". One can then typec...
I am having trouble casting an object to a generic IList. I have a group of in statements to try to work around this, but there has to be a better way to do this.
This is my current method:
string values;
if (colFilter.Value is IList<int>)
{
values = BuildClause((IList<int>)colFilter.Value, prefix);
}
else if (colFilter.Value is ...
Is it possible to cast a custom class to a value type?
Here's an example:
var x = new Foo();
var y = (int) x; //Does not compile
Is it possible to make the above happen? Do I need to overload something in Foo ?
...
Question:
Why is my C++ swigged object losing its type when passed to a Java callback function?
Setup:
I've taken the Swig Java example for doing callbacks and added an object to be passed to the callback run(Parent p). The callback works as expected but when I pass a Child object the Java seems to lose its type and think its of type Pa...
What is the difference between boxing/unboxing and type casting?
Often, the terms seem to be used interchangeably.
...
Do special processing for a type in a generic class Pinnew member dan neely 19mins ago
I'm trying to roll up some old (originally .net 1.1) abstract classes into generics. The classes in question all provide similar functionality for a data object of a specific type. For the most part things are going well, but I've ran into a few pla...
Hi Guys
I am trying to replicate TryParse for generic types and thought that TypeDescriptor might give me what I am after. So I came up with the following test case but it is failing, just wondering if anyone knows where I am going wrong.
[TestMethod]
public void Test()
{
string value = "Test";
Guid resultV...
How do I make something like user-defined __repr__ in Python?
Let's say I have an object1 of SomeClass, let's say I have a function void function1(std::string). Is there a way to define something (function, method, ...) to make compiler cast class SomeClass to std::string upon call of function1(object1)?
(I know that I can use strings...
int main()
{
float f = 12.2;
char *p1;
p1 = (char *)&f;
printf ("%d", *p1);
}
This outputs 51.
...
I have a question about technique and implementation, rather than an actual problem to solve. Recently I created an abstract class, let's called it A, which defines the common behaviors of its subclasses.
I use this to construct several subclasses B, C, and D, which are then passed to some other method outside of the superclass-subclas...
Hi
Just like we do with __ToString, is there a way to define a method for casting?
$obj = (MyClass) $another_class_obj;
...
Assuming I have an instance of an object that I know belongs to a subclass of a certain subtype passed to me through a reference of a supertype in C#, I'm used to seeing typecasting done this Java-like way (Assuming "reference" is of the supertype):
if (reference is subtype){
subtype t = (subtype)reference;
}
But recently I've come ac...
I'm using a framework which defines and uses 'ClassA', a subclass of NSObject. I would like to add some variables and functionality so naturally I created 'ClassB', a subclass of 'ClassA'
Now my problem is this. Many of the methods within this framework return instances of 'ClassA' which I would like to cast to my subclass.
For exampl...