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?
...
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...
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...
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?
...
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...
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...
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
...
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*/)
{
//...
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) {
...
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...
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 ...
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#?
...
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...
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?
...
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...
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/...
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...
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...
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...
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...