22 Discussion / Question Topics

Remove Filter
Member Avatar for
Member Avatar for edogg23

Hello. I'm trying to use SqlDataReader to return information from my database. It works fine until it comes to a datetime field. I'm getting an error saying: " Input string was not in a correct format." on the line where I'm declaring a variable to hold my field. Here is …

Member Avatar for edogg23
0
4K
Member Avatar for Razahcy
Member Avatar for sciwizeh

Hello all, I have not tested the code I'm posting here to see if it compiles, but I have an issue in a large codebase and I believe that this should be the simplest program to demonstrate the issue; class base { public: shared_ptr<base> clone()=0; }; typedef shared_ptr<base> baseptr; class …

Member Avatar for sciwizeh
0
20K
Member Avatar for James19142

I need a way to do a cast without being returned a pointer to a new address but, the same address as the original. Something like this: derivedClass something_derived; baseClass* basePointer = &something_dervived; derivedClass* derivedPointer = static_cast <derivedClass*> (basePointer); /* my problem is "derivedPointer" isnt assigned the same address as …

Member Avatar for James19142
0
185
Member Avatar for rahul.ch

import java.util.*; public class Elway { public static void main(String r[]) { ArrayList[] ls = new ArrayList[3]; for(int i=0; i<3; i++) { ls[i] = new ArrayList(); ls[i].add("a" + i); } Object o = ls; do3(ls); for(int i=0; i<3; i++) //insert code here } static Object do3(ArrayList[] a) { for(int i=0; …

Member Avatar for rahul.ch
0
284
Member Avatar for rahul.ch

Given: Sour extends Blue extends Pan `Pan p4 = new Sour();` Then set of 6 new statements given and asked to choose which ones will compile. They are: 1. `Pan p5 = p4;` 2. `Pan p6 = (Blue)p4;` 3. `Blue b2 = (Blue)b4;` 4. `Blue b3 = (Sour)p4;` 5. `Sour …

Member Avatar for JamesCherrill
0
196
Member Avatar for rahul.ch

Compiles fine. But at runtime it gives ClassCastException. My doubt is that why is it so even though st which is of type Sample1 gets casted to Sample2 and generates exception even though Sample2 IS-A Sample1.

Member Avatar for rahul.ch
0
242
Member Avatar for WolfShield

Hello everyone, I am working my way through the Forger's Win32 tutorial and am on the "Creating a Simple Application" part currently. I am using C++ (instead of C in the tutorial) and the WinGW compiler. When I compile the below code I get this error: main.cpp: In function 'LRESULT …

Member Avatar for ravenous
0
573
Member Avatar for rahul.ch

class Dog { public void bark() { System.out.println("Dog bark"); } } class Hound extends Dog { public void bark() { System.out.println("Hound bark"); } public void sniff() { System.out.println("Hound sniff"); } } public class CastingMethodCall { public static void main(String r[]) { ((Dog)new Hound()).bark(); //((Dog)new Hound()).sniff(); } } On executing above, …

Member Avatar for JamesCherrill
0
257
Member Avatar for iPanda

I got this simple code: #include "stdio.h" #include "stdlib.h" #include "windows.h" int main(int argc, CHAR* argv[]) { HANDLE hFile = NULL; HANDLE hMapFile = NULL; LPBYTE fileView; hFile = CreateFile(argv[1],GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if(hFile == INVALID_HANDLE_VALUE) { printf("CreateFile function failed\n"); goto clean; } ***** hMapFile = (LPBYTE)CreateFileMapping(hFile,NULL,PAGE_READONLY,0,256,NULL);***** if(hMapFile == NULL) { printf("CreateFileMapping function …

Member Avatar for BobS0327
0
1K
Member Avatar for Morten Brendefu

Dear knowledgeable ones. Some time ago I made a few of my routines kind of universal, and I wonder if there is any way in Delphi (My version is Delphi9) that can be used to reuse this code in example below. As you see, the two procedures are almost identical, …

Member Avatar for pritaeas
0
282
Member Avatar for dgreene1210

im getting the error below and I can't figure out why this isn't working. Ive looked at this for 2 days not knowing. I'm hoping a fresh set of eyes on it might help. main.c:13: warning: assignment makes pointer from integer without a cast [CODE] //HEADER FILE: #include <stdlib.h> #include …

Member Avatar for Ancient Dragon
0
712
Member Avatar for umair jameel

I am a beginner in programming(java) and want to know, how to do typecasting in it. show me by giving examples.

Member Avatar for stultuske
0
125
Member Avatar for bornwith

I am trying to catch the System.InvalidCastException error. If I put a number into the calculator the program runs ok. If the calculate button is pressed with nothing in the text boxes I get the casting error Conversion from string "" to type 'Decimal' is not valid. I understand why …

Member Avatar for bornwith
0
158
Member Avatar for terexberd

which of the following statements is true about casting a) you must cast to convert from an interface type to a class type. b) you must cast to convert from a class type to an interface type. c) you cannot cast to convert an interface type to a class type. …

Member Avatar for terexberd
0
95
Member Avatar for ddanbe

The next code from the book "Pro-linq language itegrated query in C# 2008" gives a casting exception error on line 29. I know ToArray returns an array of objects, which are in fact of type Employee so why it generates an error? [CODE=C#]public class Employee { public int id; public …

Member Avatar for ddanbe
0
128
Member Avatar for insanely_sane

Here's an easy one for you experts :P What is casting and parsing? How exactly are they different? After explaining, could anyone possibly tell me how to cast/parse the various types from and to each other? (the types being: int, double, char and String) Also, in which situations would I …

Member Avatar for Mattox
0
248
Member Avatar for micmo

Hi Guys, I'm currently developing a project using WCF (hosted on local IIS) which connects to a local SQL database using LINQ to get data. My problem is that when I run the code, 9/10 times it'll fail with the "Specified Cast Is Not Valid" error, but the other 1/10 …

Member Avatar for micmo
0
1K
Member Avatar for epicasian

Well, I've been Googling for at least 30 minutes, and looking through past posts about this, but just can't seem to find an answer that works. Basically, I've got a component class that has a single method I'm trying to test out. The entity class has a private array of …

Member Avatar for epicasian
0
214
Member Avatar for GBoyle

I am writing a model economy in which corporations (class BCorp) and persons (class BPrsn) act as agents buying and selling goods and services. I have a pool of contacts (class BContact) in which contact information is retained about each contact between agents. In a contact object I store a …

Member Avatar for GBoyle
0
142
Member Avatar for Sinaru

I have two classes and one of them is inherited from the other class. Class Person - used to store first name and last name of a person. The data members are protected. Class Candidate - used to store votes of an election, and this is inherited from Person class …

Member Avatar for arkoenig
0
160
Member Avatar for klactose

Hello all, I am getting the following run-time error every time I try to run a program I've converted from Lisp to C#: [QUOTE] System.InvalidCastException was unhandled Message="Unable to cast object of type 'System.Single[]' to type 'System.Collections.Generic.List`1[System.Single]'." [/QUOTE] In the function below the problem is occurring at line 16. The …

Member Avatar for privatevoid
1
237

The End.