casting

How can I cast authoritatively in asp classic?

In asp classic, the cint() function or procedure or whatever it is won't allow me to cast arbitrary strings, like "bob" or "null" or anything like that. Is there anything that will allow me to simply cast integers, numeric strings, and arbitrary strings to actual integers, with some sane default like 0 for strings? ...

In asp classic: How can I make sure that a variable can be cast as an int?

The following function was suggested to me: ' Defines a forced casting function, which "casts" anything that it can't detect as a number to zero. Function MakeInteger(val) If IsNumeric(val) Then MakeInteger = CInt(val) Else MakeInteger = 0 End If End Function Unfortunately there appear to be s...

Whats the best to way convert a set of Java objects to another set of objects?

Basic Java question here from a real newbie. I have a set of Java objects (of class "MyClass") that implement a certain interface (Interface "MyIfc"). I have a set of these objects stored in a private variable in my class that is declared as follows: protected Set<MyClass> stuff = new HashSet<MyClass>(); I need to provide a public m...

What does this C++ construct do?

Somewhere in lines of code, I came across this construct... //void* v = void* value from an iterator int i = (int)(long(v)) What possible purpose can this contruct serve? Why not simply use int(v) instead? Why the cast to long first? ...

Problem with Mapping/Casting Linq-to-Sql on different Types

Hi, maybe someone can help. I want to have on mapped Linq-Class different Datatype. This is working: private System.Nullable<short> _deleted = 1; [Column(Storage = "_deleted", Name = "deleted", DbType = "SmallInt", CanBeNull = true)] public System.Nullable<short> deleted { get { return this._dele...

Calling WPF Control Library

Hi all, When I want to show user a (windows) form which resides in a DLL (in this case Form1), I use the following code from another executable; Assembly a = Assembly.Load(System.IO.File.ReadAllBytes("mydll.dll")); Form MyDLLFormInstance = (Form)a.CreateInstance("myNamespace.Form1"); MyDLLFormInstance.Show(); Now, I created another D...

Which casting technique is better for doing casting from upper class to lower class in C++

Hi all, i want to cast from upper class pointer to lower class i.e from the base class pointer to derived class pointer. Should i use "Dynamic_cast" or "reinterpret_cast"? please advice me ...

Adding functions to Java class libraries

I'm using a Java class library that is in many ways incomplete: there are many classes that I feel ought to have additional member functions built in. However, I am unsure of the best practice of adding these member functions. Lets call the insufficient base class A. class A { public A(/*long arbitrary arguments*/) { //...

Casting to generic type in Java doesn't raise ClassCastException?

I have come across a strange behavior of Java that seems like a bug. Is it? Casting an Object to a generic type (say, K) does not throw a ClassCastException even if the object is not an instance of K. Here is an example: import java.util.*; public final class Test { private static<K,V> void addToMap(Map<K,V> map, Object ... vals) { ...

SQL:Casting a String to IDS with IN clause

DECLARE @STR_IDS VARCHAR(15) SET @STR_IDS='7,15,18' UPDATE TBL_USERS WHERE ID IN @STR_IDS I know the update statement would not work as the ID is of type INT and i am replacing a varachar value there .How can i change the query so that it will be executed like this in effect ? UPDATE TBL_USERS WHERE ID IN (7,15,18) Thanks in advac...

Safe to cast pointer to a forward-declared class to its true base class in C++?

In one header file I have: #include "BaseClass.h" // a forward declaration of DerivedClass, which extends class BaseClass. class DerivedClass ; class Foo { DerivedClass *derived ; void someMethod() { // this is the cast I'm worried about. ((BaseClass*)derived)->baseClassMethod() ; } }; Now, DerivedClass is (in ...

C#: do enums cast themselves as strings or integers as appropriate in the context

If I have the enum: public enum VehicleType { Car = 0, Boat = 1, Bike = 2, Spaceship = 3 } and I then do: int X = 10; VehicleType vt = (VehicleType)2; X = X + vt; Console.WriteLine("I travel in a " + vt + " with " + X + " people."); What should the output be in C#? ...

IGrouping and Casting in Linq

I have the following query: var groupCats = from g in groups group g by g.Value into grouped select new { GroupCategory = grouped.Key, Categories = GetCategories(grouped.Key, child) }; This works fine. In the anonymous type returned GroupCateg...

Haskell : Type casting Int to String

I know you can convert a String to an number with read like so: Prelude> read "3" :: Int 3 Prelude> read "3" :: Double 3.0 But how do you grab the string representation of an Int value? ...

Poblem with "CFDataRef".

Hello I have a problem with "CFDataRef. I get the "data" field from a "kCFSocketDataCallBack. "data" should correspond to a string received on the socket. How do I convert, for example, in a NSString so I can put my text in a textbox?? Thank you very much static void AcceptDataCallback(CFSocketRef s, CFSocketCallBackType type, CFDat...

"possible loss of precision" is Java going crazy or I'm missing something?

I'm getting a "loss of precision" error when there should be none, AFAIK. this is an instance variable: byte move=0; this happens in a method of this class: this.move=(this.move<<4)|(byte)(Guy.moven.indexOf("left")&0xF); move is a byte, move is still a byte, and the rest is being cast to a byte. I get this error: [javac] /Users/...

How can I extend a LINQ-to-SQL class without having to make changes every time the code is generated?

Hi, Update from comment: I need to extend linq-to-sql classes by own parameters and dont want to touch any generated classes. Any better suggestes are welcome. But I also don't want to do all attributes assignments all time again if the linq-to-sql classes are changing. so if vstudio generates new attribute to a class i have my own e...

Implicit Type Conversions in Reflection

So I've written a quick bit of code to help quickly convert between business objects and view models. Not to pimp my own blog, but you can find the details here if you're interested or need to know. One issue I've run in to is that I have a custom collection type, ProductCollection, and I need to turn that in to a string[] in on my mode...

How do I DYNAMICALLY cast in C# and return for a property

I've already read threads on the topic, but can't find a solution that fits. I'm working on a drop-down list that takes an enum and uses that to populate itself. i found a VB.NET one. During the porting process, I discovered that it uses DirectCast() to set the type as it returns the SelectedValue. See the original VB here: http://je...

Assigning a float to a decimal property via a style setter in WPF

I have the following xaml in a template for a lookless control: <Style x:Key="NumericUpDownStyle" TargetType="controls:NumericUpDown"> <Style.Setters> <Setter Property="Change" Value="{x:Static local:Preferences.ChangeAmount}"/> </Style.Setters> </Style> Where the 'Change' property on the 'NumericUpDown' control is a d...