conversion

Convert to a Nullable<T> from a string using Reflection

How can I convert TO a Nullable from a String using reflection? I have the following code to convert TO almost any value type given almost any value. There is quite a bit of code above this to use the IsAssignableFrom, etc. so this is the last resort. MethodInfo parse = t.GetMethod("Parse", new Type[] { typeof(string) }); if (parse ...

What is the right way to convert a string to an unknown numeric type?

I am creating a type converter for use in a in-house library that should be able to convert from any type returned by a database (long, DBNull, bool, string, etc...) to any compatible type. This all works fin and dandy for items that can either be casted: try { return (T)value } catch(InvalidCaseException) { } Or can be parsed: see ...

Converting x/y values in camera view to pan/tilt values

Hi, I'm not very good with more advanced maths, so I have to ask this: If I have a camera which gives out 360 degree pan (x) and tilt (y) values, and I want to get the pan and tilt values of where I have my cursor in the camera's view, how would I convert that? More info: It's a Flash/AS3 project. The pan and tilt values are from the c...

Convert EPS/PDF to JPEG/PNG?

Hi I need to be able to take EPS and PDF's and convert them to JPEG/PNG on the fly to display on a website - using .net code. I used ADC PDF from WebSupergoo for this like 3 years ago, and it worked fine - but some other and better options could easily have surfaced since then. ...

Best way to do a split and convert the result into ints

I have a DB table that contains a comma separated list of ID's (ints) that are stored as nvarchar. I have a get method to return these in one hit as a list. At the moment I think I'll have to do something like this: List<int> ids = new List<int>(); string[] pageids = experssion.Split(separators) foreach (string number in pageids) {...

HTML to text conversion in shell script

I wrote a shell script to convert HTML source to plain text using lynx. Here it is: #!/bin/sh if [ -f = "/usr/bin/lynx" ] then if [ -f = "$1" ] then lynx -dump $1 > $2 else echo "File $1 does not exist!" fi else echo "Lynx is not installed!" fi Now, although lynx exists in the right direct...

Conversion of text to picture-message?

Friends, I need to know how to convert a text to a picture-message(.ota) format in JAVA for sending through mobiles? I am developing a software that sends the picture-message to another mobile via serial-port. Could anyone help for creating a routine for the conversion process? I need that routine to converts the given text/picture to a...

c#: copy variable to byte array

Hi How do I copy a double, int, bool or other built-in type to a byte array in C#? I need to do it to use the FileStream.Write() method. ...

Convert Ruby code to string

I am refactoring some code that I did not write, and I found a line that looks like this (it is much longer, i used just a little bit for this example): system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control');") To increase readability, I refactored it to do_something = "rubyw -e \" require 'win32ole' ...

Converting mp3 bitrates using lame_enc.dll or similar.

I need to programatically convert mp3's of any bitrate to a standard bitrate for streaming audio using c#. Currently a buffer is populated with mp3 data from disk and then send out to the "listeners" at what should be a constant speed (the broadcast), but the mp3's could be of any bitrate. This makes timing extremely difficult and should...

How can I convert from an array of struct to array of Point3D ?

Hi All, I want to convert an array of struct to array of Point3D. The code snippet is as follows : class Mymesh { public MeshGeometry3D Mesh3D // Properties tanimlaniyor { get { return GetMesh3D(); } } public struct mystruct { public int m_i; public int m_j; public int m_k; public mystruct(int i, ...

Declaring arrays with data is easy in C# - how can I do it in VB?

Possible Duplicate: Anonymous class initialization in VB.Net Trying to convert examples like this from C# to VB.Net leaved me scratching my already bald head...: public ActionResult GridData(string sidx, string sord, int page, int rows) { var jsonData = new { total = 1, // we'll implement later page = page, recor...

Is there a better way than int( byte_buffer.encode('hex'), 16 )

In Python, I'm constantly using the following sequence to get an integer value from a byte buffer (in python this is a str). I'm getting the buffer from the struct.unpack() routine. When I unpack a 'char' using byte_buffer, = struct.unpack('c', raw_buffer) int_value = int( byte_buffer.encode('hex'), 16 ) Is there a better way? ...

TRY CATCH on a CONVERT in a Select Statement

Is it possible to use TRY CATCH blocks in SQL Selects? For stuff similar to this for example: select order, CONVERT(DATETIME, orderDate) from orders What's the best way of handling this scenario? ...

How can I fix an int-to-bool warning in C++?

I get a warning in MSVC++ when I try to read an integer from a file and make a bool variable equal it. accessLV[i] = FileRead(file1, i + 1); (accessLV is an array of bools, FileRead is a function I made to decrease the syntax involved in reading from a file, i is because the statement is within a for loop) I've tried using a static_c...

Convert String to code in Java

I want to know if there is any way to convert a String to Java compilable code. Explanation: I have a comparative expression saved in a database field. I want to retrieve it from database, then evaluate it inside a conditional structure. Is there any way to do this? ...

Rails: How do I save a string representation back into a model?

I have an Employee model that has a SecurityClearanceLevel. When you make a new employee, you're asked to set a SecurityClearanceLevel by choosing from a <select> list. The problem is that when I save the object, it's a string, not a SecurityClearanceLevel, so the save fails. Where do I take care of this kind of back-and-forth conversio...

Converting Greek characters to Unicode

Is there any easy way of converting a windows-1252 string into a Unicode one? ...

How to extract data from a PDF file while keeping track of its structure?

My objective is to extract the text and images from a PDF file while parsing its structure. The scope for parsing the structure is not exhaustive; I only need to be able to identify headings and paragraphs. I have tried a few of different things, but I did not get very far in any of them: Convert PDF to text. It does not work for me a...

CAST incorrectly casting float to varchar

Group, I am sure this is user error somehow, but I am trying to CAST a column of numbers from a float to a varchar. It works great for anything under 7 digits, but if the number is 7 digits it turns it into scientific notation or what ever they call that. For example: 440000 displays 440000 1299125 displays 1.29913e+006 It looks like...