What’s Wrong With This Code? (#26)

Posted by: K. Scott Allen, on 24 Jan 2011 | View original | Bookmarked: 0 time(s)

A measurement consists of a high reading and a low reading, but the high and low values are optional. We also need to add measurements together, so the following C# code: var m1 = new Measurement(lowValue: 3, highValue: 5); var m2 = new Measurement(null, 3); var m3 = new Measurement(6, 2); Console.WriteLine(m1 + m2 + m3); should produce a total measure showing a low value of 9, a high value of 10 (effectively ignoring null values). Unfortunately, something is wrong with the implementation... public...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: C# | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 473 | Hits: 58

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD