tostring

Convert numbers with toString in Ansi C

Is it possible to use toString operator, or how to convert numbers to char arrays. ...

Visual Basic - Sending a Carriage Return to an E-Mail

How can I send a string to an email with new lines (carriage returns) included? The problem is that I am sending the string to an email, and the email strips out the carriage returns. Dim myApp As New Process emailStringBuilder.Append("mailto:") emailStringBuilder.Append("&subject=" & tmpID & " - " & subject) emailString...

[Flex] How to print out an object memory address at runtime? like this.toString() in java.

How to write an AS3 object's memory location for example to a label? I need it for debugging purposed. Thanx ...

What are the original reasons for ToString() in Java and .NET?

I've used ToString() modestly in the past and I've found it very useful in many circumstances. However, my usage of this method would hardly justify to put this method in none other than System.Object. My wild guess is that, at some point during the work carried out and meetings held to come up with the initial design of the .NET framewo...

In Java, how do I get the value of an enum inside the enum itself?

I want to override toString() for my enum, Color. However, I can't figure out how to get the value of an instance of Color inside the Color enum. Is there a way to do this in Java? Example: public enum Color { RED, GREEN, BLUE, ... public String toString() { // return "R" for RED, "G", for GREEN, etc. }...

when to use toString() method

This may sound very basic... can someone please explain the use of the toString() method and when to effectively use this? Have done a search on google but could not find any good resource. ...

vb.net currency display has four zeros instead of two

when i get the money field from sql server to vb.net code, i always get 1.0000 instead of 1.00. how do i convert this to 1.00 in vb.net? TD = New HtmlTableCell If Not SqlDR("Price") Is DBNull.Value Then TD.InnerHtml = SqlDR("Price") Else TD.InnerHtml = "0.00" End If SQLDR is my sql data reader ...

Custom .ToString() Formats in .rdlc Reports

I have a custom business object which overloads the .ToString() function. It also implements IFormattable.ToString, so I can define my own custom formats. This approach seems to work everywhere in my app, except .rdlc reports. For example, I have a text field on a report with the following expression: =Fields!MyField.Value.ToString("lr...

Best way to add a string based constructor to a Java class?

Say I have some class, e.g. Foo: public class Foo { private Integer x; private Integer y; public Foo(Integer x, Integer y) { this.x = x; this.y = y; } public String toString() { return x + " " + y; } } Now, I wish to add a constructor which takes as its argument a string representing ...

Is there an equivalent to Java's ToStringBuilder for C#? What would a good C# version feature?

In the Java world we have Apache Commons' ToStringBuilder to help with creating toString() implementations. ( http://commons.apache.org/lang/api/org/apache/commons/lang/builder/ToStringBuilder.html ) Does anyone know of a decent free implementation for C#? Are there better alternatives I don't know about? If no free implementation exis...

Entities equals(), hashCode() and toString(). How to correctly implement them?

I'm implementing equals(), hashCode() and toString() of my entities using all the available fields in the bean. I'm getting some Lazy init Exception on the frontend when I try to compare the equality or when I print the obj state. That's because some list in the entity can be lazy initialized. I'm wondering what's the correct way to fo...

C# Double - ToString formatting with two decimal places and no rounding

How can i format a Double to String in c# so as to have only two decimal digits? If I use String.Format("{0:0.00}%", myDoubleValue) the number is rounded, and i want a simple truncate without rounding. Also, I want the conversion to String to be culture sensitive. ...

toString method for varargs contructor

I have a varargs contructor like this : public class Sentence { public String[] str; public Sentence(Object... text){ StringBuilder sb = new StringBuilder(); for (Object o : text) { sb.append(o.toString()) .append(" "); } System.out.println(sb.toString()); } } Con...

How are integers converted to strings under the hood?

I suppose the real question is how to convert base2/binary to base10. The most common application of this would probably be in creating strings for output: turning a chunk of binary numerical data into an array of characters. How exactly is this done? my guess: Seeing as there probably isn't a string predefined for each numerical value...

In what scenario would one need to use PHPs magic function toString()

Why would a programmer need to use the function? How would the same results have been achieved in php 4? ...

Display part of an XML file while parsing it

Hey, Consider the following XML file : <cookbook> <recipe xml:id="MushroomSoup"> <title>Quick and Easy Mushroom Soup</title> <ingredient name="Fresh mushrooms" quantity="7" unit="pieces"/> <ingredient name="Garlic" quantity="1" unit="cloves"/> </recipe> <recipe...

JavaScript using toString on a Function object to read text content

Calling toString() on the function below returns different strings across browsers. I understand this is because ECMA-262 15.3.4.2 leaves wiggle room for each vendor. Chrome returns the comments in addition to all syntax. Sadly Firefox 3.6 omits the comments. Based on Firefox's behavior I haven't tested IE, Opera, or Safari. functio...

Auto-generating toString Method

Is it good or bad practice auto-generating toString methods for some simple classes? I was thinking of generating something like bellow where it takes the variable names and produces a toString method that prints the name followed by its value. private String name; private int age; private double height; public String toString(){ r...

Creating a custom format string in a dataGridView

I have a dataGridView whose dataSource is a dataTable. My problem is that I want certain columns to be displayed in Hex. I can get that far with using something like this: foreach (DataGridViewColumn c in grid.Columns) { if (DISPLAYED_IN_HEX.Contains(c.Name)) { c.DefaultCellStyle.Format...

convert ArrayList.toString() back to ArrayList in one call

I have a toString() representation of an ArrayList. Copying the toString() value to clipboard, I want to copy it back into my IDE editor, and create the ArrayList instance in one line. In fact, what I'm really doing is this: my ArrayList.toString() has data I need to setup a unit test. I want to copy this ArrayList.toString() into my...