Hi, I'd like to set a property of an object through reflection, with a value of type string.
So, for instance, suppose I have a Ship class, with a property of Latitude, which is a double.
Here's what I'd like to do:
Ship ship = new Ship();
string value = "5.5";
PropertyInfo propertyInfo = ship.GetType().GetProperty("Latitude");
propert...
How can I convert the following struct to unsigned char*?
typedef struct {
unsigned char uc1;
unsigned char uc2;
unsigned char uc3;
unsigned char uc5;
unsigned char uc6;
} uchar_t;
uchar_t *uc_ptr = new uchar;
unsigned char * uc_ptr2 = static_cast<unsigned char*>(*uc_ptr);
// invalid static cast at the previous line...
I need to perform calculations with a symbol. I need to convert the time which is of hh:mm form to the minutes passed.
;; (get-minutes symbol)->number
;; convert the time in hh:mm to minutes
;; (get-minutes 6:19)-> 6* 60 + 19
(define (get-minutes time)
(let* ((a-time (string->list (symbol->string time)))
(hour (first a-time)...
Hi Guys
I am trying to replicate TryParse for generic types and thought that TypeDescriptor might give me what I am after. So I came up with the following test case but it is failing, just wondering if anyone knows where I am going wrong.
[TestMethod]
public void Test()
{
string value = "Test";
Guid resultV...
I'm writing a computer graphics application that makes use of several different libraries that provide many of the required features.
For example, in college I wrote quaternion, optimized 3 vector, and optimized 4x4 matrix classes that I like to use since they are efficient and I'm very familiar with them. I also wrote a K-D Tree imple...
I'm converting a small MSAccess application to a web-based ASP.NET app, using C# 3.5. I was wondering what's the best way to work with dates in C#, when converting some of this VBA code over to C#.
Here is an example of the VBA Code:
Coverage1=IIf(IsNull([EffDate1]),0,IIf([CurrDate]<=[EndDate1],[CurrDate]-[EffDate1],[EndDate1]-[EffDat...
I need to convert a C/C++ double to a 64 bit two's complement, where the Radix point is at bit number 19 (inclusive).
This means that for the format I want to convert to
0x0000 0000 0010 0000 is the number 1
0xFFFF FFFF FFF0 0000 is the number -1
0x0000 0000 0000 0001 is 0.95 x 10^-6
0xFFFF FFFF FFFF FFFF is -0.95 x 10^-6
So far ...
Why, with a generic constraint on type parameter T of class P of "must inherit from A", does the first call succeed but the second call fail with the type conversion error detailed in the comment:
abstract class A { }
static class S
{
public static void DoFirst(A argument) { }
public static void DoSecond(ICollection<A> argument...
I need to use a binary data in a transformation as an integer and do some manipulation, but how to do the casting? I tried many SSIS data types but no luck. By the way I do not want to use script task.
[Updated section below]
The data is the values stored in the __$update_mask column of the CDC function fn_cdc_get_net_changes. Follow...
As some of my code required implicit conversion between matrices of different types (e.g. Matrix<int> to Matrix<double>), I defined a templated copy constructor Matrix<T>::Matrix(Matrix<U> const&) instead of the standard Matrix<T>::Matrix(Matrix<T> const&):
template <typename T> class Matrix {
public:
// ...
template <typename U...
The question is in the title I guess.
This is the temporary solution I came up with but I was wondering:
If there are disadvantages to representing binary as char*. Is there a better way (considering i would want the ability of bit-shifting etc...)
If there is obvious non-idiomatic C (or other errors) in the code below.
All suggesti...
Hi,
In Groovy you can do surprising type conversions using either the as operator or the asType method. Examples include
Short s = new Integer(6) as Short
List collection = new HashSet().asType(List)
I'm surprised that I can convert from an Integer to a Short and from a Set to a List, because there is no "is a" relationship between t...
For some strange reason, when I move a PHP file from one folder to another, Vista copies an old version of the file instead of the current version. This really screws up the web application I'm working on and causes me to waste time in figuring out the problem.
What the hell is going on here and how do I prevent Vista from copying or m...
From The C Programming Language 2nd Edition:
Since an argument of a function call is an expression, type conversions also take place when arguments are passed to function. In absence of a function prototype, char and short become int, and float becomes double.
By reading the text, I am getting an impression that unless you explicit...
Hi
We're just getting into MVVM in WPF.
We have implemented our ViewModels with 'strongly typed' properties (int, double? etc.) that we bind to in the view.
Type conversion works OK, mostly, and so entering data is simple enough. But we run into problems with validation.
If, say, a non-numeric value is entered in a text box bound to ...
I'm wondering why the following code doesn't work:
String test = new String(new byte[] {92, 92, 92, 92, 92});
System.out.println(test);
String compare = "\\\\\\\\\\";
System.out.println(compare);
if (test == compare) {
System.out.println("Yes!");
}
The output is:
\\\\\
\\\\\
Where is a data type conversion happening that I'm not un...
I would like to write a class looking like this:
class Store[+A](dest: Symbol)(implicit c: String => A) extends Action(dest) {
override def update(options: HashMap[Symbol,Any], arg: String): Unit = {
options += ((dest -> c(arg)))
}
}
object Store {
def apply[A](dest: Symbol)(c: String=>A) = new Store[A](dest)(c)
def apply[A...
Hi there,
I need an sql query to give me the following:
All the values in a column of type varchar(50) which will NOT convert or will throw an error if cast / converted to an int.
E.g.
row 1: '1'
row 2: '2'
row 3: '3a'
row 4: '4.5'
I need row 3....however there are tens of thousands of rows.
Thanks!
...
Is there any difference between type casting & type conversion in c++.
...
I usually avoid VB's built-in conversion functions (CStr, CDate, CBool, CInt, etc.) unless I need to do an actual conversion. If I'm just casting, say from an object to a string, I normally use either DirectCast or TryCast, under the assumption that CStr, etc., are doing some extra stuff I don't need. But sometimes the DirectCast syntax ...