types

Using enum to represent IDs in C#

I was using plain ints to represent some IDs internally but I needed a constant to represent a null ID, while I was playing around I realised that this would work: public enum ID : int { Null = -1 } then for example: ID myID = ID.Null; Is this a bad idea? Is it worse that just using plain ints? If it is a problem, what is the best ...

How do you pass an array by reference in Delphi?

I already read up about passing by reference and so procedure test(var x:integer); begin x:=x+5; end; so the above code updates 5 by reference. I assumed if I was updating an array by reference I could declare var X: array of blah... having some bound bugs and just wanted to know if I should be using the type of data for the pointer...

Defining types from other units in Delphi

Var A : Array [1..4] of Integer; B : Array [1..4] of Integer; Begin A := B; Won't work as loren-pechtel said here the problem is A and B for me are in different units. So, is there a way to define a type definition from a existing one in another class? ...

Conversion from 'xxxx' to 'yyyy', possible loss of data, suppression?

Sometimes I've got warnings with conversion from a longer type to a smaller type e.g.: void f( unsigned short i ) // f - accept any numeric type // smaller than std::vector<>::size_type {} std::vector < some_type > v; .. f ( v.size() ); Usually I was using one of next solutions: assert( v.size() <= std::...

Converting (void*) to std::vector<unsigned char>.

I have a (void*) buffer that I need to convert to std::vector<unsigned char> before I can pass it on. Unfortunately, my C++ casting skills a little weak. Any suggestions? ...

Query Lua userdata type from C

I have a Lua userdata object with a certain metatable type (e.g. "stackoverflow.test"). From C code, I want to be able to check exactly which type it is, and behave differently depending on the results. Is there a nice handy function (rather like luaL_checkudata, but without erroring if the answer isn't what you want) that let's me query...

What happened to MEF type, "AttributedAssemblyPartCatalog"?

Many simple MEF examples (listed below) uses AttributedAssemblyPartCatalog. Hosting MEF in an application on CodePlex MEF page Simple Introduction to Extensible Applications with the Managed Extensions Framework by Brad Adams Managed Extensibility Framework Tutorial - MEF by David Hayden I have downloaded MEF source from CodePlex but...

How to create keywords/types in C#?

Duplicate typedef in C#? Is there a way to create actually keywords in C#. Like for example turning object x into a datatype like int? I guess I'm asking is there anything like a typedef for C# and if not how can I actually make my own types that look like this: public static crap Main(string[] args) { // Note 'crap' and not...

C: Why isn't size_t a C keyword?

sizeof is a C keyword. It returns the size in a type named size_t. However, size_t is not a keyword, but is defined primarily in stddef.h and probably other C standard header files too. Consider a scenario where you want to create a C program which does not include any C standard headers or libraries. (Like for example, if you are creat...

How does the .NET runtime determine that two types are the same?

Hello, I have assembly A that depends (statically) on type T (reference type, a class) in assembly B. I do not own assembly A but I do own assembly B. T unfortunately is a real type (not an interface) but luckily A uses reflection to discover its members. I want to be able to create dynamically B (and T). The only important item is th...

Ensuring C++ doubles are 64 bits

In my C++ program, I need to pull a 64 bit float from an external byte sequence. Is there some way to ensure, at compile-time, that doubles are 64 bits? Is there some other type I should use to store the data instead? Edit: If you're reading this and actually looking for a way to ensure storage in the IEEE 754 format, have a look at Ada...

How to tell if an instance is of a certain Type or any derived types

I'm trying to write a validation to check that an Object instance can be cast to a variable Type. I have a Type instance for the type of object they need to provide. But the Type can vary. This is basically what I want to do. Object obj = new object(); Type typ = typeof(string); //just a sample, really typ is a variable ...

In Delphi, how can you check if an IInterface reference implements a derived but not explicitly-supported interface?

If I have the following interfaces and a class that implements them - IBase = Interface ['{82F1F81A-A408-448B-A194-DCED9A7E4FF7}'] End; IDerived = Interface(IBase) ['{A0313EBE-C50D-4857-B324-8C0670C8252A}'] End; TImplementation = Class(TInterfacedObject, IDerived) End; The following code prints 'Bad!' - Procedure Test; Var A : ...

Convert a double to a String in Java and vice versa without losing accuracy

A String representation of a double is written to and read from a file by a C# application. The C# application converts the double to a string using the following fragment: value.ToString("R", NumberFormatInfo.InvariantInfo); The C# application converts the string to a double using the following fragment double num = double.Parse(s,...

VC++ compiler and type conversion?

When I moved a program from a Mac to this Windows PC, the VC++ 2008 compiler is giving me errors for passing unsigned ints to the cmath pow() function. As I understand, this function is not overloaded to accept anything but floating-point numbers. Is there some compiler flag/setting that will ignore these errors? Also does anyone know h...

Access Query Error - Null & Variant Data Types - How do I fix this error?

All, This error is driving me insane. I've spent 2 hours trying to figure it out and/or work around it with no luck. Here's the error: "You tried to assign the NULL value to a variable that is not a Variant data type." Here's my SQL: SELECT tbl_budir_002.Location_Index, tbl_parent_001.NEWPARENTID INTO tbl_budir_003 FROM (tbl_budi...

Fortran 90, Questions about Array & Derived Type

I have questions about Arrays and Derived Types. For my new project, I have to use an array instead of a scratch file to store information from users. To do this, I need to create derived types, too. However, I haven't understood what an array is and what a derived type is, how to use them, what they can do, and some other basic ideas. ...

How to detect a property return type in Objective-C

Hello, I have an object in objective-c at runtime, from which I only know the KVC key and I need to detect the return value type (e.g. I need to know if its an NSArray or NSMutableArray) of this property, how can I do that? ...

What is double(C++) in C#?

What is the double type(C++) in C#? double experience; At first,I thought its UInt32,but its not. How to declare it in C#? ...

Passing a particular WebControl type as a parameter in VB.net

I'm trying to create a function that searches up a WebControl's parent-child relationship (basically the opposite of WebControl.FindControl(id as String), but looking for a specific WebControl type). Example: I have a user control in an ItemTemplate for a GridViewRow. I'm trying to reference the GridViewRow from the user control. The ...