Click here to Skip to main content
15,888,351 members
Everything / Conversion

Conversion

conversion

Great Reads

by NightWizzard
Convert amounts to their spoken equivalents
by Yisrael Lax
Library that provides custom casting functionality from one type to another between properties with disparate names and types
by ToughDev
Code to set and get current time using the RTCC module on PIC24
by Johannes Bildstein
A library for colormodels and spaces, correct color-conversions and color-difference calculation.

Latest Articles

by ToughDev
Code to set and get current time using the RTCC module on PIC24
by Thorsten Bruning
Converting nearly every type to another type
by Cinchoo
Tip to split large JSON file based on deeply nested array property using Cinchoo ETL
by Cinchoo
Use Cinchoo ETL to deserialize selective XML nodes from large XML file

All Articles

Sort by Score

Conversion 

20 Aug 2015 by Sergey Alexandrovich Kryukov
By default, C string is marshaled as .NET string in P/Invoke. To be certain, you can use the attribute System.Runtime.InteropServices.MarshalAsAttribute:https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute%28v=vs.110%29.aspx[^].The attribute should be...
28 Aug 2015 by Sergey Alexandrovich Kryukov
Wrong question. First, video is not converted to audio (what it would even possibly mean?) It's just video files contain several streams, and some of them are video, and some are audio, and you can have some different kinds of streams (subtitles, for example). So, you can first extract some...
15 Mar 2016 by Jochen Arndt
A simple method would be using CStringT::Format[^]:CString str;str.Format(_T("%u.%u.%u.%u"), (unsigned char)ipaddr[3], (unsigned char)ipaddr[2], (unsigned char)ipaddr[1], (unsigned char)ipaddr[0]);Note the casting to unsigned char. It tells the compiler to treat the signed char...
18 Dec 2016 by NightWizzard
Convert amounts to their spoken equivalents
6 Sep 2012 by JF2015
See this link:http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]
2 Mar 2013 by Maciej Los
As far as i know, there are no automation tool.You can use: http://converter.telerik.com/[^], which converts vb to C#, but vb is not vbs, it's similar to vb. See Key differences between VB and VBScript[^]
4 Dec 2013 by Maciej Los
Please read my comment first.Generally, to convert data from one type to another, please use: CAST and CONVERT (Transact-SQL)[^][EDIT]Reply to OP comment. No, it's not enough information. There are few version of MS SQL Server. Some of them does not provide time data type.DECLARE @t...
4 May 2014 by leon de boer
This is a complicated task I did the first part of a task in an old articleConnected Component Labeling and Vectorization[^]That creates little line segments that form the connected part of the image but to really do anything useful you now have to run recognition and/or filters on it....
3 Oct 2014 by George Jonsson
This might be helpful: Adler-32 Checksum Calculation[^]
12 Aug 2015 by OriginalGriff
"Infact person class being ancestor has lesser features than Employee, So Employee object must be able to accommodate a person object without any explicit casting. Please elaborate."No, it's the other way round.Because Employee is derived from Person, a Person variable can freely contain...
24 Apr 2018 by Yisrael Lax
Library that provides custom casting functionality from one type to another between properties with disparate names and types
6 Sep 2012 by __TR__
VB.Net to C# Converter[^]Good way to convert VB.Net to C#?[^]More links here[^]
7 Sep 2012 by Espen Harlinn
Have a look at the free .Net IDE SharpDevelop[^] - it performs code conversion pretty well.Best regardsEspen Harlinn
22 Oct 2012 by parths
A couple of changes I would suggest are,The largest positive number is 0x7fff / 0x8000. So instead of dividing by 32767, we need to divide by 32768.Also, change the 'unsigned int F' declaration to 'short'. What this will do is give you the 2's complement negative number which you're looking...
22 Oct 2012 by Jochen Arndt
According to the documentation signed numbers are represented in the two's complement format. To convert them you may use this:// Get the absolute number masking out the sign bitint n = ((msg0 & 0x7F)
26 Mar 2013 by Sergey Alexandrovich Kryukov
Both formats, and a lot more, are supported by FFmpeg or libavcodec, which are the best libraries I know. Please see:http://en.wikipedia.org/wiki/Ffmpeg[^],http://ffmpeg.org/[^],http://en.wikipedia.org/wiki/Libavcodec[^],http://libav.org/[^].You can use them on the server-side either...
13 Oct 2013 by Ron Beyer
Unfortunately Windows is not a real-time operating system and its difficult to get the same (or close to the same) time on two different threads. Maybe your answer is doing post-processing instead of trying to get the values while also collecting data. For example, collect the data, save it to a...
7 Feb 2014 by Richard C Bishop
I believe the declaration of "@Period" as a DATETIME is skewing the data you think you are getting. If "@Period" is not going to be dynamic and will always be '2013/01/01' then I would make it a VARCHAR(15) data type. If it is a dynamic date, then try converting that date into the varchar format...
3 Mar 2014 by BillWoodruff
Yes, you can sort the values in an Enum for display in a ComboBox alpha-numerically, or any other way you want:// requires Linq// preserve the current ComboBox selectionprivate V currentVName;private void Form1_Load(object sender, EventArgs e){ var vAry =...
11 Jun 2014 by Richard Deeming
Something like this should work:Public Overridable Sub ReadRecordFromDb(Of T As Class)(ByVal ID As Integer) ... ' find the primary key field name by checking for IsPrimaryKey Dim pk As String = dataMembers.Single(Function (m) m.IsPrimaryKey).Name ' return a...
28 Nov 2014 by OriginalGriff
Try:TimeSpan ts;if (TimeSpan.TryParseExact("143522.666", @"hhmmss\.fff", CultureInfo.InvariantCulture, out ts)) { Console.WriteLine(ts); }
13 Apr 2015 by OriginalGriff
Don't.Never store DateTime values in a DB as a string: parse them at point of input (or as close as you can get) because only then can you tell what format the user has input them in, and that they are correct. It's far too late by the time they get to the database as they have lost all user...
16 Oct 2015 by Jochen Arndt
It seems that your input values are not integers (have decimal places = digits after the decimal mark). When casting such floating point values, the decimal places are ignored. To implement rounding to nearest, add 0.5 before casting:int val = static_cast(someDoubleVal + 0.5);The next...
19 Mar 2016 by Jochen Arndt
You must parse the string to get the four elements, convert these to numbers, and combine the numbers to a DWORD (assuming an IPv4 address in dotted notation; your CString.Format example misses the periods in it).There are various methods to perform the parsing:Using sscanf, _sscanf_l,...
5 Nov 2017 by Patrice T
Your code is a mess of cascading conversions, you need to check that every conversion works as expected, use the debugger to do so. BigValue and TenBase are BigInteger, and you want TenBase = ToTenBase(BigValue, 3) see what you do with ToTenBase ToTenBase does BigValue as BigInteger => ToString...
31 Mar 2018 by Mehdi Gholam
Most likely a shortcoming of the compiler processor, i.e. the compiler takes one side of the ':' as the output type (probably the left) and assumes the second (right) must match otherwise throws and error without checking the inheritance tree in the case of Dog and Cat and the left side of the...
6 May 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
22 Jan 2019 by Richard Deeming
That code is reading the contents of a file which you have previously opened. You will presumably have a previous line that looks something like: Open EncryptedFilePath For Input As #EncryptedFileNumber File IO is much easier in .NET - the System.IO namespace[^] gives you all the tools you...
1 Jan 2020 by Richard MacCutchan
1. Learn C++ 2. Write the application in C++. Sorry, but this site does not provide free coding or conversion services.
3 Mar 2021 by CPallini
In addition to other solutions: Don't use float unless you have very good reason for. Use double instead. Your code should handle incorrect user choice. The cm to inch formula in your code is wrong. Try #include int main() { ...
7 Jun 2021 by Richard MacCutchan
Use the %X format type in your printf statement: printf - C++ Reference[^]
6 Sep 2012 by Amund Gjersøe
According to Microsoft you should be able to use BmpBitmapDecoder (or the decoder of choice). I've tested, and it worked:Stream bmpStream = new System.IO.FileStream("smiley.bmp", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);BmpBitmapDecoder bmpDecoder = new...
24 Sep 2012 by JF2015
Hi,see the answers to this similar question:how to convert numbers into texual format using c#[^]
24 Sep 2012 by CPallini
Google is your friend.See, for instance, converting numbers in to words C#[^] at stackoverflow.
24 Sep 2012 by Rajesh Anuhya
Hi, Have you tried in Google/CP? Here is the CP link for you.How to convert a numeric value or currency to English words using C#[^]and here Google[^] Try in Google/CP before posting a QuestionThanks--RA
10 Oct 2012 by bbirajdar
Don't be lazy. Grow up. How long will you be dependent on others just to search on google ?I got this links in 10...
1 Nov 2012 by OriginalGriff
First off, that isn't a good question.It contains no detail of what you want, and makes no real sense.Secondly, that isn't how it works. The idea is: You try to do it, you get stuck, you ask for help.Just asking for code will not please anyone, and will result in you not getting...
1 Nov 2012 by OriginalGriff
Binary, octal and hex are all the same in this context - you just need to convert the string to bytes:string s = "Hello!";byte[] bytes = System.Text.Encoding.ASCII.GetBytes(s);
20 Nov 2012 by R. Giskard Reventlov
One way is to read the file into a string and then parse the string to replace commas with a tab character except when the comma is inside a pair of single or double quotes.You will also have to handle when a comma is used as a decimal separator. So, there's a hint: now write some code and,...
20 Dec 2012 by Prasad_Kulkarni
Refer:XPS to PDF Converter DLL Library[^]Convert XPS files to PDF format[^]XPS to PDF Converter Command Line from C#[^]
13 Jan 2013 by Abhinav S
This error may actually have nothing to do with the size of the excel. One of the rows after row 20000 may have some data that may be of a different type. It will be worth doing a quick data validation of the Excel file.
14 Jan 2013 by user_code
Hello,I have a HWND in my C++ MFC code, and I want to pass this HWND to a C# control and get it as IntPtr.What Is wrong in my code, and how can I do it correctly?(I think it's something with wrong using of the CLI pointers, because I get an error that it cannot convert from...
25 Feb 2013 by Joezer BH
Hello Guilherme,There is no out of the box solution, as it is not clear what xml schema you need.However, that is fairly simple, since you can easily implement:1. reading the excel with C#2. create your xml file with C#Hers's an example for reading an excel:var fileName =...
28 Aug 2013 by CPallini
You may easily transform your input string into a CDate function accepted one, just using the Mid function (optionally you may use also Left and Right) and the string concatenation operator.
6 May 2014 by sandeep12jain
you can achieve by these link http://encosia.com/easy-incremental-status-updates-for-long-requests
3 Jul 2014 by CHill60
Here is one technique...1. Download a free PDF creator e.g. http://www.pdfforge.org/pdfcreator[^] or http://www.cutepdf.com/[^] ... there are others2. If your free PDF creator doesn't hook to the Explorer context menu (right-click on a file to check) then set your default printer to...
28 Nov 2014 by OriginalGriff
Try this: double d = 12.345678; Console.WriteLine("{0,8:000000.00}", d); Console.WriteLine("{0}", d.ToString("000000.00"));
12 Jan 2015 by Kornfeld Eliyahu Peter
You should use Google more...CDC - Class (of) Device Context...Device Context in GDI is the logical surface to draw on within your application...http://msdn.microsoft.com/en-us/library/dd162467(v=vs.85).aspx[^]In .NET (C#) the closest thing to it is the Graphics[^] class, which is more...
7 Mar 2015 by Sergey Alexandrovich Kryukov
Yes and no. No, because you are totally confused, and, formally, the questions don't even make sense. You cannot say "conversion" and "extract source code". There is nothing to extract. Source code is not contained in the assembly modules. It is not "kept". You just don't understand.At the...
7 Mar 2015 by manchanx
In addition to what Sergey wrote and answers to the questions in your comment:Quote:You say .Net Assemblies, i say .Net Application, same thing?.Net Assemblies are either Executables (.exe) or Dynamic Link Libraries (.dll) which are being used by Executables. Usually you refer to an...
13 Apr 2015 by Member 10987276
I have converted a c++ project(which runs) to c# where it throws a null reference exception here is a small samplepublic class EQSTATE{...public double lg; // low gain...}EQSTATE es;init_3band_state(es, 880,5000,480000);Thenprivate void init_3band_state(EQSTATE es, int lowfreq,...
17 Apr 2015 by Wendell D H
I looked for ways to do it with Array.ConvertAll, but was having trouble.But this should work.This assumes you don't know the sizes of the array dimentions//Your original objectobject saMatrix = new object[3, 3] {{ 11.0, 12.0, 13.0 }, { 21.0,...
19 Jun 2015 by Sergey Alexandrovich Kryukov
It simply means that the H₂O was stored in the database as Unicode, using one of the UTFs (the subscript code point U+2082, "subscript two") and you wrote the Unicode string in one of the non-Unicode encodings, such as ASCII. The question mark you got is the usual "fallback" character used when...
7 Jul 2015 by Andy Lanng
Wow! I am sooo good to you!There is no Bengali calendar in .Net. I think this is an oversight so I made one!!!It's a rough cut but it worksI know, right: I'm frickin' AWESOME!usage:var thisDate = DateTime.Now;BengaliCalendar bCal = new...
12 Aug 2015 by Andy Lanng
See solution one.Interfaces work a little differently. They are not an object assigned into memory, but just pointers to an existing objects memory.Take a look at this: private static void Main() { Employee employee1 = new Employee(); ...
21 Sep 2015 by Dave Kreskowiak
There is no way to speed that up. The operation is completely out of your control.You can TRY other PDF libraries, such as CutePDF and "printing" the word document to a PDF file, but you'll likely end up with the same problem.
25 Jan 2016 by OriginalGriff
Start by using the debugger.Create a file which contains 4 bytes with hex values 00 FF 55 AARun your app, and look at the resulting file. It should be00000000111111110101010110101010And nothing else.Now use that file as the input to your ConvStep2 method, and put a break point on the...
10 Mar 2016 by OriginalGriff
Um.That string string string1 = "7210110810811132119111114108100";Isn't ASCII.ASCII is a character set, in much the same way as UNICODe is, but a lot smaller. Each character has a value: H would be 72 decimal, or 48 Hex, or (unusually these days) 110 in Octal. Your string may contain some...
19 Mar 2016 by OriginalGriff
In theory, you can just cast it - but that's risky, because a char array or char pointer doesn't have to be aligned to an address boundary, and a DWORD does. And you shouldn't use char anyway, as it's a signed value - you really want byte instead.So I'd do this:DWORD DwordFromBytes(byte...
14 May 2016 by PJ Arends
Use the %X type specifier in your CString::Format call. Do not bother with the WideCharToMultiByte stuff if you are working in UNICODE, just keep every thing in UNICODE.CString str;str.Format(L"%X", x);Lookup CString::Format in MSDN
22 May 2016 by George Jonsson
You can do something like this.#define LENGTH 8 // Use constants instead of numbersint numbers[LENGTH];numbers[0] = 1; // LSBnumbers[1] = 0;numbers[2] = 1;numbers[3] = 1;numbers[4] = 0;numbers[5] = 0;numbers[6] = 1;numbers[7] = 1; // MSBunsigned char result =...
11 Oct 2016 by Ali_100
I am in trouble, tried many times but could succeed , foreach (var tempitem in mbsRateTempList) { foreach (var Saveditem in mbsSavedRecordList) { if (tempitem.MbsSecurityId == Saveditem.MbsSecurityId && tempitem.CouponRate ==...
20 Dec 2016 by OriginalGriff
Looking at your other questions, I can't help feeling that you are committing yourself to something way out of your league. This is not a simple task - the major companies in this industry have been working on similar projects for years, with massive teams and significant funding, and have got a...
29 May 2017 by CPallini
Of course it is possible. However it couldn't be an automatic process and, depending on the application complexity (you said nothing about) it could be time consuming.
4 Nov 2017 by OriginalGriff
Why are you using strings? That's very wasteful and inefficient. Instead, use the BigInteger Divide and Modulus operations to extract each digit one at a time, and include it in a running total: set powerOf = 1 set total = 0 while input not zero extract lowest digit using modulus 10 ...
7 Nov 2017 by Kenneth Haugland
Have you heard of Horner's method[^]? It can remove the need to take the power of numbers, and you generally don't want to do that, since it is very slow. The call and check code is: string input = "22222222210222211011111222011100022001111"; string Base = "012"; ...
1 Apr 2018 by BillWoodruff
When you specify the return Type, and the ternary values that may be returned are of different Types, the compiler must check if a Type conversion is possible. These work because the compiler can determine there is a conversion possible: bool boolVal = true; Animal a1 = boolVal ? new Dog() :...
6 May 2018 by Richard MacCutchan
You can go to The Java™ Tutorials[^] to learn some of the things you missed. Or, better still, go and talk to your teacher and ask for the missing notes.
21 Oct 2018 by Daniel Pfeffer
15 seconds of Google found this: General Porting Guidelines | Microsoft Docs[^] Which discusses issues in conversion of 32-bit Windows code to 64-bit. See also the subjects in the menu on the left of the screen.
29 Oct 2018 by OriginalGriff
This depend son what you want to do: manually via an app, or programatically - the two are different. Via an app: Open it in your new, shiny image editing program (or Paint, if that's what you have available) Use "Save as" (often hotkeyed to F12) and select TIFF as the output format. Give it a...
29 Jan 2019 by User 11060979
I'm not sure what your problem exactly is, a.) OpenGL? b.) Calculations? From your question I see you recognized how to come from 3D- XYZ Space to xy(Y) space. Anyway: Here you will find a set of formulas from convert from Spectrum to XYZ on from there to xyY, sRGB, etc. and vice versa (of...
3 Mar 2019 by Mehdi Gholam
Read this : c# - Convert from Word document to HTML - Stack Overflow[^]
1 Jan 2020 by OriginalGriff
Even if we provided such a service (which we don't) I'd strongly suggest that you don't do it. When you translate languages, what you end up with isn't "more efficient"; quite the reverse, it's normally less efficient than the original because it isn't designed to work well in that language....
28 Mar 2020 by OriginalGriff
We are not a code conversion service: in addition translating code for one language to one using a totally different framework never gives "good code" in the target language. Instead, find some code that is in the correct language, or learn both...
11 Apr 2020 by Dave Kreskowiak
What nobody has mentioned yet is that you cannot use Office Interop, in your case Excel, in a web application. It may work fine on your machine, but in a multi-user app and deployed to a web server, Office is not supported. On the "Access...
8 May 2020 by RickZeeland
For an example of .ContinueWith() see: Chaining Tasks by Using Continuation Tasks | Microsoft Docs[^] It should look like this: taskA.ContinueWith(Sub(antecedent) Console.WriteLine("Today is {0}.", antecedent.Result) End Sub) You might...
24 Feb 2021 by Dave Kreskowiak
There's no such thing as a "global" variable in C#, or .NET really. You're not going to "detect" anything happening to a variable. However, you can store what you consider "global" data in Properties in a static class. The property get/set code...
26 Feb 2021 by BillWoodruff
imho: using a bunch of bytes to store information that requires parsing to interpret is, generally, a bad idea. While you can simulate "global" variables in C# using static Fields, or static Properties, or certain Types declared as Const...
25 Feb 2021 by Patrice T
Quote: How would I go about it, and what would be the most time efficient way to do it? Assuming the byte array is fixed length fields, butchering a byte array is so basic operations that it is difficult to see a difference of efficiency between...
12 May 2021 by CPallini
Here we go... #include int main() { if ( printf("code")
7 Jun 2021 by CPallini
You know, there is not an 'hexadecimal format' for a file. However, there could be a file containing the hexadecimal representation of binary (as well ASCII) data. To obtain such a file replace (as already suggested by Richard) Quote:...
6 Sep 2012 by MitchG92_24
Hi All,I have a DLL which outputs a BitmapImage for me, however i need a BitmapFrame.I've tried to use BitmapFrame.Creat... to no avail.Any ideas on how to convert a System.Windows.Media.Imaging.BitmapImage to System.Windows.Media.Imaging.BitmapFrame?Thanks in advance!
24 Sep 2012 by WebMaster
My form have 2 textboxes. For one text box i'm entering a number & when it's done i need to get the digit value in string format in other text box. Is this possible?Ex: TextBox1 --> 100 TextBox2 --> One Hundred
22 Oct 2012 by ad_robot
Hi Everyone, I'm trying to interpret some data from an embedded sensor device into a C++ program. The device uses a numerical format called 1.15 fractional format. This means it transmits 2 hex bytes into a value rangle of ~1
1 Nov 2012 by OriginalGriff
If you mean to VB then there are a number of on-line converters which can help. I use this one: http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
1 Nov 2012 by CafedeJamaica
ASP .Net will work with C#, if you read up on how to create a class in C# you can reuse all the code you have written in the project you are trying to convert to ASP .NET.
1 Nov 2012 by Deenuji
i want to generate public key and secret key based on any algorithm??? but those generation is based on our uploading file(text)?
1 Nov 2012 by Deenuji
1st write this function on your page:public static string ConvertToBin(string asciiString) { StringBuilder sb = new StringBuilder(); foreach (string letter in asciiString.Select(c => Convert.ToString(c, 8))) { sb.Append(letter); } ...
2 Nov 2012 by CafedeJamaica
You can do this using certificates, if you create your own certificates using a certification authority or by using visual studio(link following) http://msdn.microsoft.com/en-us/library/ms733813(v=vs.100).aspx[^]then you can use the following code to do your encryptionCryptography...
6 Nov 2012 by Member 9550902
How to do date conversion on mysql
16 Nov 2012 by Jackie00100
Hi people, I've ran into a problem where i wanna downcast a object of a different type to a object longer down in a derived hierarchy, i think the best way is just to show some simple code:class mammal {}class dog : mammal{}class cat : : mammal{}class program{ public main() ...
16 Nov 2012 by Rohit Shrivastava
I don't think that make any sense downcasting an object, just assume cat has an extra property called CapacityToDrinkMilk which is integer that tells how much milk a cat can drink. What do u expect while downcasting in that property? which leads an object with wrong properties. You can create a...
30 Nov 2012 by harish.puramsetti
Can any one help me for converting the below code of Perl to C#?use strict;my $usage =
30 Nov 2012 by codeninja-C#
Hi,You can easily do this task with c# without converting perl script. At first understand the logic of above code.Your output shows that it generate all the possibilities of color,car,time which is based on your test cases and text.txt file.--SJ
6 Dec 2012 by Deenuji
Actually i'm using color extender to pick the color in asp.net...but while i'm picking the color it generate the hex decimal values....but i need only rgb values...Pls any one guide me....
6 Dec 2012 by IpsitaMishra
Try this I hope It will help youHow to convert Hexadecimal Color to RGB color (24 Bit)[^].keep smiling :):):) haapy coding:)
7 Dec 2012 by Zafar Sultan
Have a look at this link:http://snipplr.com/view/13358/[^]
7 Dec 2012 by Richard MacCutchan
Why have you posted this question when you have already been given the answer in the C# forum? Please post in one place only, and do not spam the forums.
7 Dec 2012 by Deenuji
Solution:Write this coding in button or whatever... System.Drawing.Color MyColor = System.Drawing.Color.FromArgb(val);
10 Dec 2012 by TuanNGUYEN
Hi all,I am programming a window service (c#), which convert a doc/docx file to html.After test unit, everything is very OK, but when it run it service mode, it throw an exception when saving the doc file to html.Following is my codes:object srcFile = sourceFile;object dstFile =...