type-conversion

Converting Types

I was trying to convert an object with Object type into FontUIResource type. In Java, it would be FontUIResource font = (FontUIResource)value How would I do that in Scala? ...

I need to convert an XML string into an XmlElement

I'm looking for the simplest way to convert a string into an XmlElement in C#. Thanks ...

How to convert a string representing decimal number in exponential form to float in Qt?

I have some decimal numbers in a text file represented in exponential form Eg: 144.2e-3. I want to store the values in float. In qt it returns "0" when i directly use the "number.toFloat()" method. Please help. ...

Cannot implicitly convert type 'customtype' to 'othercustomtype'.

Hi, I am new to C#. I have a Persons class and a User class which inherits from the Persons class. I my console I input a users in an array. Then I can add a note to a user that is in the users array by only entering the users id. In my Persons class i have this function that has to search if this user is in the users array. public stat...

SQL Server types conversion

Possible Duplicate: sql server year EXACT duplicate of sql server year DECLARE @FINANCIALYEAR AS varchar(30) DECLARE @FINALFINANCIALYEAR AS int SELECT @FINANCIALYEAR=CONVERT(VARCHAR,YEAR(GETDATE())-2) + ', ' + CONVERT(VARCHAR,YEAR(GETDATE())-1) + ', ' + CONVERT(VARCHAR,YEAR(GETDATE())) set @FINALFINANCIALYEAR = ...

how to convert number to string (without exponent)

hey there! sorry, but i'm not that maths guy, so i do not know how it is really called: number 12345678901234567890123 could be also stated as 1.2345678901234567890123 * 10^22 (if i'm right and did not miss any decimal...) consider this javascript: var number = 12345678901234567890123; var stringValue = number.toString(); if i do s...

What type-conversions are happening?

#include "stdio.h" int main() { int x = -13701; unsigned int y = 3; signed short z = x / y; printf("z = %d\n", z); return 0; } I would expect the answer to be -4567. I am getting "z = 17278". Why does a promotion of these numbers result in 17278? I executed this in Code Pad. ...

Type conversion with Generic List and Interfaces in C# - Looking for an elegant solution.

Take the following example (created purely to demonstrate the point). What I am trying to do is isolate one part of the system from another and only want to expose a specific subset of the functionality externally from the assembly while internally working against the full objects methods. This code compiles, but I get an invalid cast ...

User-defined type conversions in ActionScript?

Is there any way for me to define implicit or explicit type conversions in ActionScript? For instance, I want to define a conversion such that Array can cast into MyClass implicitly. If not, an explicit cast would be useful. I know I can always pass it into my constructor, but I am dealing with semantics here, and I am most interested...

Java type conversion where types are not known until runtime

I'm trying to write a data access layer for an AJAX web project. This DAL has to convert data coming in via an AJAX servlet to objects that can be passed to a PreparedStatement for execution. Data in the AJAX servlet, retrieved by using HttpServletRequest.getParameter(...), come in as strings. In each data class, I have a known set of ...

What does 401F0000C48FBAA6 mean?

Hello, I have this text 401F0000C48FBAA6 and I know that corresponds to a word. It's not in hexadecimal (I've tried). Do anyone knows in what base can it be? And what does it means? ...

What's the reason of using implicit/explicit convertions instead of constructors?

An example would be: XNamespace ns = "my namespace" Why not?: XNamespace ns = new XNamespace ( "my namespace" ) What's the idea behind using implicit/explicit convertions instead of constructors? Convenience? Is there a guideline for this? ...

extending Convert.ChangeType to produce user-defined types on request

Given the class: public class Foo { public string Name { get; set; } } Is it possible to have a Foo instance created from a string through Convert.ChangeType: Type type = typeof(Foo); object value = "one"; value = System.Convert.ChangeType(value, type); This is how a 3rd party API is attempting to rebuild objects. Someone men...

Change only parts of a type in a C++ template

Purpose and craziness aside, is there a way to achieve this in C++? template <typename P> void Q void_cast(P Q *p) const { return static_cast<P Q *>(p); } I'm effectively trying to cast a pointer to a void pointer type whilst keeping any const, restrict and other qualifiers (denoted by Q). I was under the impression there was stu...

Problems with calculations and conversions in Visual Basic Form

In the code below I get the "Conversion from string "" to type 'Double' is not valid." error. Can anyone let me know why this is ? Thanks. Public Class Form1 Dim SalesDecimal As Decimal Const BasePay As Decimal = 250D Const CommissionRate As Decimal = 0.15D Dim Quota As Integer = 1000 Dim TotalSalesAmt, TotalComAmt,...

How to do a static cast in C#?

Given a couple types like this: interface I {} class C : I {} How can I do a static type cast? By this I mean: how can I change its type in a way that gets checked at compile time? In C++ you can do static_cast<I*>(c). In C# the best I can do is create a temporary variable of the alternate type and try to assign it: var c = new C();...

Where do you put the parentheses to concisely convert a casted object to a primitive type without auto-unboxing?

With autounboxing, this statement will automatically work: int myPrimitive = (Integer) doIt(); But if I want to explicitly convert from an Integer to an int here in a single line, where do I have to put the parentheses? ...

How to convert UNIT of MEASURE in SQL SERVER OR ORACLE USING CASE STATEMENT

Hi, Is there a way in SQL SERVER or ORACLE that can use the case statment to convert the Unit of Measure below? select UoM, sum(Quantity) as 'QTY' from mytable group by UoM UoM QTY LBS 2.4 LBS 2 LBS 0.233 LBS 0.97 OZS 1.8 GMS 1236 LBS 120.459 LBS 59.1 LBS 252.82 LBS 175.23 LBS 3.42 LBS 455.4 LBS 57.6 LBS 146.8 LBS 117.78 LBS 197.92 L...

How to perform unsigned to signed conversion in Java?

Say I read these bytes: "6F D4 06 40" from an input device. The number is a longitude reading in MilliArcSeconds format. The top bit (0x80000000) is basically always zero and is ignored for this question. I can easily convert the bytes to an unsigned integer: 1876166208 But how do I convert that unsigned value into its final form of 3...

What is guaranteed about the size of a function pointer?

In C, I need to know the size of a struct, which has function pointers in it. Can I be guaranteed that on all platforms and architectures: the size of a void* is the same size as a function pointer? the size of the function pointer does not differ due to its return type? the size of the function pointer does not differ due to its param...