I am attempting to do some data conversion. Unfortunately, much of the data is in strings, where it should be int's or double, etc...
So what I've got is something like:
double? amount = Convert.ToDouble(strAmount);
The problem with this approach is if strAmount is empty, if it's empty I want it to amount to be null, so when I add i...
Given a string:
String exampleString = "example";
How do I convert this to an InputStream?
...
Hi,
I'm going to try to make myself clearer. Why does C# accept the following:
object o = "hello";
int? i = o as int?;
if (i == null) {
// o was not a boxed int
}
else {
// Can use i.Value to recover the original boxed value
}
and not
String = "hello";
int? i = o as int?;
if (i == null) {
// o was not a boxed int
}
else {
// Can u...
Some code for context:
class a
{
}
class b
{
public a a{get;set;}
public static implicit operator a(b b)
{
return b.a;
}
}
a a=null;
b b=null;
a = b;
//compiler: cannot apply operator '==' to operands of type tralala...
bool c = a == b;
Is it possible to use == operator on different type instanc...
I'd like to create a generic method for converting any System.Enum derived type to its corresponding integer value, without casting and preferably without parsing a string.
Eg, what I want is something like this:
// Trivial example, not actually what I'm doing.
class Converter
{
int ToInteger(System.Enum anEnum)
{
(int)...
How do I convert a CString to a double in C++?
Unicode support would be nice also.
Thanks!
...
Example: "20080807144334.410187-180" (-180 means GMT minus three hours. Rio de Janeiro in this case.)
That string format is returned when I query file creation/change/access times via WMI (that is not totally working; see here). I guess I could parse it the idiot way, extracting year, month etc. from the string positions. But I'd like n...
I would like to implement a general purpose runtime type conversion function that makes use .Net TypeConverters to do the conversion.
Does anyone know how to how to look up and invoke a TypeConverter for a particular type?
Consider this C# example:
//
// Convert obj to the type specified by 'toType'.
//
object ConvertTo(object obj,...
Being a starting Objective-C developer, and not having the patience to actually do some studying, rather than just diving into things, I ran into the following:
I have a CGFloat, and I want to divide it by something, and use the result as an NSInteger.
Example:
CGPoint p = scrollView.contentOffset; //where p is a CGFloat by nature
NSI...
I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following:
A * getAnObject()
{
if(someBoolean)
return (A *) new B;
else
return (A *) new C;
}
Where "A" is the parent of classes "B" and "C". One can then typec...
Let us say I have a textbox or any other form of input that asks for a social security number. I do want to note that the SSN is a pure example I simply thought of as of right now.
This input will naturally be stored as a string initially.
string s = Console.ReadLine();
Let us say I want to have a method that validates an SSN and it m...
I am using SPFieldCurrency column in one of my lists.
My custom code receives a string value as a parameter, which contains the field's value as returned by the GetFormattedValue() method.
Now my problem is that the value received by my method contain currency symbols in them, Eg, 10$, 10¥, 10€ etc.
Because of the presence of the curr...
Both queries below translates to the same number
SELECT CONVERT(bigint,CONVERT(datetime,'2009-06-15 15:00:00'))
SELECT CAST(CONVERT(datetime,'2009-06-15 23:01:00') as bigint)
Result
39978
39978
The generated number will be different only if the days are different. There is any way to convert the DateTime to a more precise number, a...
Is there efficient way to do this?
...
Hi,
I wanted to convert array< Byte>^ to unsigned char*. I have tried to explain what i have done. I donot know how to proceed further. Please show me the right approach. I am using MS VC 2005.
//Managed array
array<Byte>^ vPublicKey = vX509->GetPublicKey();
//Unmanaged array
unsigned char vUnmanagedPublicKey[MAX_PUBLIC_KE...
I'm sure this is an easy question, but I don't have an answer for. Here's the senario and the question.
I have an array that was stored using in a particular format. The format contains a Header record with muntiple detail records following it. The header of the record tells me what TypeCode was used to store the data, for instance I...
When I compile the following code using g++
class A {};
void foo(A&) {}
int main()
{
foo(A());
return 0;
}
I get the following error messages:
> g++ test.cpp -o test
test.cpp: In function ‘int main()’:
test.cpp:10: error: invalid initialization of non-const reference of type ‘A&’ from a temporary of type ‘A’
test.cpp:6: er...
I'm working on code that does nearest-neighbor queries. There are two simple ideas that underlie how a user might query for data in a search:
closest N points to a given point in space.
all points within a given distance.
In my code, Points are put into a PointList, and the PointList is a container has the job of keeping track of the...
Hey everyone,
I'm trying to create some CRUD functionality for a legacy database and using the Entity Framework as an ORM tool. One table, 'Sites', has a Guid type 'Id' column which is never seen by the users and an integer type 'SiteId' which the users use to identitfy a Site.
For god knows what reason the numeric SiteId column is of ...
Hi folks,
I have a class named "baseClass".
From this class I inherit a class names "inheritedClass" (public class inheritedClass: baseClass)
The baseClass contains a public function that returns a HashSet<baseClass>. When called from the inheritedClass, the return type is obviously still HashSet<baseClass>, but I need a HashSet<inheri...