.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Extend Double type
 

Extend Double type

I'am programming some software for a bookshop. I have been using 'double' type for entering my ISBN numbers. but recently i found out that sometimes the check-sum character is a roman number 'X'.

How can i 'extend' the definition of what a double character is that it will accept the 'X'? If it is not possible i need to rewrite all my source code so please help me out.
Jan_Antwerp
Wow. Using Double is dangerous anyways. A double isn't precise, like ISBN numbers are. You should have at least been using a decimal.

That being said, use a string for an ISBN number. You can't extend double without creating another custom class. Just can't be done. The type is sealed.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki �LinkedIn �ForumsBrowser
  • Marked As Answer byJan_Antwerp Wednesday, September 09, 2009 7:00 PM
  •  
David M Morton
Wow. Using Double is dangerous anyways. A double isn't precise, like ISBN numbers are. You should have at least been using a decimal.

That being said, use a string for an ISBN number. You can't extend double without creating another custom class. Just can't be done. The type is sealed.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki �LinkedIn �ForumsBrowser
  • Marked As Answer byJan_Antwerp Wednesday, September 09, 2009 7:00 PM
  •  
David M Morton
In that case: how can i create a new costum class and adapt the decimal type there?
Jan_Antwerp
public class ISBN
{
public double NumericPortion { get; set; }
public string TextPortion { get; set; }

public override string ToString()
{
return TextPortion + NumericPortion;
}
}

?

Use a string instead.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki �LinkedIn �ForumsBrowser
David M Morton

You can use google to search for other answers

Custom Search

More Threads

• should we put our ADO.Net objects in data tier or biz tier
• copying files indicating the status of the copying
• Overrides ToString in System.Enum
• How to set an Attribute to dynamically created class instance (with use a TypeBuilder)
• String.Remove(int32) convenience
• Packaging applications
• Slow load of projects in VS.net and how to make StringBuilder like for arrays marshalling
• Event driven stopwatch
• Active Directory USer List error
• Decimal question