type-conversion

How to dynamically load (and use) .net library with properly established dependencies using library versions?

Situation overview. We have several projects used in multifunctional system. objectAccessLibrary.dll (multiple versions) dispatcherHandler.dll (v.1.0) (dependency: version independent part of objectAccessLibrary.dll) Event handlers: handler_01.dll, handler_02.dll, handler_03.dll. Dependencies: dispatcherHandler.dll (v.1.0), objectA...

how to cast from one type to another in c

I have following code #include <stdio.h> #include<ctype.h> typedef struct { int Type; int Type2; }foo; typedef struct { char cData[40]; }bar; int main() { bar b1; strcpy(b1.cData,"11"); foo *f=(struct foo *)&b1; printf("Type is %d \n",f->Type); return 0; } But i am not getting the value of type 1 in f's pointer , i...

JPA Typed Search Queries

I have a rather big model Applicant: public class Applicant{ private Long id private String name; ... ... } To populate a selection list, I need a list of (id, name) tuples and I use this search query: public List getNames() { Query query = em.createQuery("select a.id, a.name from Applicant a"); return query.getResultL...

Convert hexadecimal to octet format

Hi, the ifconfig output of my machine is the following: :~ shell$ ifconfig en0 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:25:bc:e7:39:6a inet6 fe80::225:bcff:fee7:396a%en0 prefixlen 64 scopeid 0x4 inet 10.170.133.45 netmask 0xffffff00 broadcast 10.170.133.255 media: autoselect (100...

My generic type converter smells bad, exceptions at runtime, object as catch all, boxing etc.

Firstly, I've asked this question elsewhere, but meta.stackoverflow.com seems to think that asking the same questions elsewhere is fine, so here goes. I'll update both if/when I get an answer. I'm doing a lot of conversion between simple types and I wanted to handle it as nicely as possible. What I thought would be nice would be to be a...

How can I use reflection to convert from int to decimal?

I have some code (which works fine) that looks something like this: int integer = 42; decimal? castTo = integer; Then I wanted to do something similar with reflection, with some code that looks like this: object value = source; // source was an int originally var parameters = new object[1]; ... parameters[...

How to convert delegate to identical delegate?

There are two descriptions of the delegate: first, in a third-party assembly: public delegate void ClickMenuItem (object sender, EventArgs e) second, the standard: public delegate void EventHandler (object sender, EventArgs e); I'm trying to write a method that will receive a parameter of type EventHandler and will call third-party...

Type mismatch between ? and java.Object in Map<String,?> <==> map.put("str", new Object())

Can someone explain the following error (from eclipse IDE): The method put(String, capture#1-of ?) in the type Map is not applicable for the arguments (String, Object) Received on line 3 of the code blow: public class MyTest { public void populateUserLoggedIn(Map<String, ?> model){ model.put( "test", new Object()...