Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. ICustomFormatter and IFormattable

ICustomFormatter and IFormattable

Scheduled Pinned Locked Moved Visual Basic
questionhtmlcomdiscussion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jason McBurney
    wrote on last edited by
    #1

    I am looking at these two different interefacing sytems within the framework, ICustomFormatter and IFormattable, and I trying to digest the pros and cons of each. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcompositeformatting.asp[^] Discusses some of the ordering differences, but I would like your opinions! What is the differnce in this two interfaces? do you need to investigate an online backup[^] company

    D 1 Reply Last reply
    0
    • J Jason McBurney

      I am looking at these two different interefacing sytems within the framework, ICustomFormatter and IFormattable, and I trying to digest the pros and cons of each. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcompositeformatting.asp[^] Discusses some of the ordering differences, but I would like your opinions! What is the differnce in this two interfaces? do you need to investigate an online backup[^] company

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      ICustomFormatter lets you define entirely custom formatter for your object. You don't have to impement or specify which standard formatting codes, like G or N, that your formatter supports because you're providing the ENTIRE formatting implementation yourself, including parsing custom formatting commands in the format string (object.ToString("customFormattingCodes"). You're extending the standard set of codes with your own. The IFormattable interface says that you're not extending the existing set of foratting codes, but just providing custom implementations for the standard set of codes, with respect to the current culture. At a minimum, your code must support the standard formatting code "G", or General format. You can supply custom formatters for any and all of the standard formats. For example, consider the "C", Currency format. There is a standard implementation for a floating point number and returns a string representation of the number, formatted to what is specified in the current culture. You could implement your own, similar functionality on any of your own custom objects, even those that don't directly represent a number. Your custom formatter for Currency would respond to the standard format string "C", like this: myCustomObject.ToString("C"). RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups