I don't understand why in some cases I can make an explicit cast and in other cases I can not. Thanks to all!
//DAreaLabel extends Message
//This Code Works
List<Message> list1 = (List<Message>)
Arrays.asList((Message[]) getPageRecords(getClasspath(), methodName, object));
DAreaLabel areaLabel = (DAreaLabel)
((List<M...
I have a class (TabControlH60) that both inherits from a base class (UserControl) and implements an interface (IFrameworkClient). I instantiate the object using the .NET Activator class. With the returned instance, I can cast to the UserControl base class, but not to the interface. The exception I get is below the code snipet. How do I c...
How to get the Label of Ribbon command that is executed. Information is present in sender object but how to cast it in RibbonCommand and then I can get that command name
private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
RibbonCommand rbnCmd = sender as RibbonCommand;
}
But in this case rbnBmd remains...
I want to use a temporary MEMORY table to store some intermediate data, but I need/want it to support TEXT columns. I had found a workaround involving casting the TEXT to a VARCHAR or something, but like an idiot I didn't write down the URL anywhere I can find now.
Does anyone know how to, for example, copy a table x into a memory table...
I have this function:
Program A
public ICollection<ReportLocationInfo> GetAllReportsInstalled()
{
return _Reports;
}
I am calling it through reflection dynamically:
Program B
internal ICollection<Object> Scan(string path)
{
MethodInfo GetReports =
_reportFactoryType.GetMethod("GetAllReportsInstalled");
ret...
Hello,
I am using boost::any to have polymorphic types, I need to be able to cast an object to its base type.
class A {
public:
int x;
virtual int foo()= 0;
};
class B : public A {
public:
int foo() {
return x + 1;
}
};
int main() {
B* bb = new B();
boost::any any = bb;
bb->x = 44;
A...
I have a function with prototype void* myFcn(void* arg) which is used as the starting point for a pthread. I need to convert the argument to an int for later use:
int x = (int)arg;
The compiler (GCC version 4.2.4) returns the error:
file.cpp:233: error: cast from 'void*' to 'int' loses precision
What is the proper way to cast this...
(OK, I'll expose the depths of my ignorance here, please be gentle)
Background
I've got a method which looks (a bit) like this:
public void AddLink(Enum enumVal)
{
string identifier = m_EnumInterpreter(enumVal);
AddLink(identifier);
}
The EnumInterpreter is a Func<Enum, string> that is passed in when the parent class is cr...
Hello!
I wanted to write a standard stack in C but I am not sure if my stk_size() function could work on other platforms except for my 32bit pc. I read that its not good to cast a pointer to int.
But what could be a better implementation? I dont want to add a "size"-variable because its redundant in my eyes.
Here are some parts of the ...
int a;
printf("%d\n", a);
I wonder if %d is a cast?
...
Hi, all
I have tried to cast to float numbers from string in the database fields to compare with another numbers. The field in the database was String type. I have tried to use BETWEEN criteria using cast() as " cast(field, float) BETWEEN 1.003 AND 100.00)" in the where statement. however, it does not help.
however, when I tried to ex...
Possible Duplicate:
Puzzling Enumerable.Cast InvalidCastException
Hi,
I just noticed something quite strange with the Enumerable.Cast<T> extension method... It seems that it can't cast from int to long, even though this cast is perfectly legal.
The following code fails with an InvalidCastException :
foreach (var item ...
I'm currently trying to take a string ("0.1") and convert it to a double using C++ in Xcode on 10.6 with gcc4.2.
I'm using a function I pinched from another question, but when I try to use the function, my input according to gdb is (string)"0.1", but my output is (double)2.1220023981051542e-314.
Here is my snippet copied straight out t...
Chosen Solution
Thanks for the help everyone. I've decided to do the following.
public static class PersonCollection
{
public static List<string> GetNames(RecordCollection<Person> list)
{
List<string> nameList = new List<string>(list.Count);
foreach (Person p in list)
{
nameList.Add(p.Name)...
How to do this in Delphi:
procedure ToggleVisibility(ControlClass : TControlClass);
var
i : integer;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is ControlClass then
ControlClass(Components[i]).Visible := not Control(Components[i]).Visible;
end;
Compiler doesn't allow the cast in this case. Any ideas?
I'm...
How to cast from hexadecimal to string in C?
...
The following complies but at run time throws an exception. What I am trying to do is to cast a class PersonWithAge to a class of Person. How do I do this and what is the work around?
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
class PersonWithAge
{
public int Id { get; set; }
public string Name { ...
Here's the scenario i am faced with:
public abstract class Record { }
public abstract class TableRecord : Record { }
public abstract class LookupTableRecord : TableRecord { }
public sealed class UserRecord : LookupTableRecord { }
public abstract class DataAccessLayer<TRecord> : IDataAccessLayer<TRecord>
where TRecord : Record, n...
I read a few posts on the usage of static and dynamic casts specifically from http://stackoverflow.com/questions/332030/when-should-staticcast-dynamiccast-and-reinterpretcast-be-used
I have a doubt regarding the usage of cast in the following manner. Can someone verify the below mentioned code:-
This is upward casting in inheritance hi...
In MySQL 5.1, why won't this SQL work correctly?
SELECT CAST (20091023 as date);
[I've just figured out the answer to this question myself-- and I'll answer it myself below-- but the behavior was so odd that I wanted to capture it as a StackOverflow Q&A pair so others won't waste time on the same problem.]
...