Every class in .NET should have a meaningful ToString method. ToString magically and automatically converts an object into a human-readable string representation of itself. It’s not quite serialization, but it’s certainly a close cousin. using System; class ToStringExample1 { public static void Main() { int x = 0; int y = 0; try { y [...]
Tag Archives: Object
concatenating delimited strings from object properties Asp.Net C#
Posted by james on April 28, 2011
0 comments
The sample code we’ve looked at so far has been reasonably simple. Let’s look at a more difficult problem—building a delimited list composed of values that are calculated from object properties. Suppose we have a simple class named Party: PartyDemo.cs (excerpt) public class Party { public Party(DateTime partyDate) { this.partyDate = partyDate; } public DateTime [...]