Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:16:20+00:00 2026-06-02T02:16:20+00:00

System.Convert has a really useful utility for converting datatypes from one type to another.

  • 0

System.Convert has a really useful utility for converting datatypes from one type to another. In my project, I have many custom types. I want to convert command line arguments to these custom types (some of which are quite complex). It would be nice if these existed within System.Convert so I could just do something like this:

Convert.ToMyCustomType(args[1])

I’d like for this to show up in the Visual C# IDE as I type. I know that I could simply create a routine to convert types but I would like the type conversions to be handled in the same manner as what’s already built into the framework. Has anyone had success doing this in the past?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:16:21+00:00Added an answer on June 2, 2026 at 2:16 am

    No, you can’t add them to the Convert class – I would suggest adding conversion methods to your actual types, such as:

    MyCustomType.FromInt32(...)
    

    and instance methods going the other way:

    int x = myCustomType.ToInt32();
    

    (Static factory methods are often better than adding lots of overloaded constructors, IMO. They allows various alternatives – including returning a null value where appropriate, or caching – and can make the calling code clearer.)

    I would also strongly recommend that you don’t go overboard on the number of conversions you supply. Not many custom types really have a single natural conversion from all kinds of primitive types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you convert a System.Drawing.Bitmap image to another type of image? I tried
Is there a way to convert from System.Windows.Forms.HtmlElement to mshtml.IHTMLElemenet3? --edit after answer accepted
I'm receiving this error in my Linq statement --- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable'
while doing LINQ I got this Error. Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'.
I have a system that is performing many XSL transformations on XMLType objects. The
OK, so I have a database field of type char(1) that has a small
How to convert system.windows.controls.control.background(brush) to bitmap?Thanks.
How do I best convert a System.Data.DbType enumeration value to the corresponding (or at
How can I convert a System.Windows.Media.Brush to System.Drawing.Brush? I'm trying to get the color
Is there a simple way to convert a System.Drawing.Pen into its unmanaged counterpart? Like,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.