473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Overriding system.convert

Hello,

We have a fairly large application that makes a great deal of use of the System.Convert class, mostly to convert strings from form fields into Int32. Usually we do something like this:
Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.     return Convert.ToInt32(this.txtSomeField.Text);
  4. }
  5. catch
  6. {
  7.     return -1;
  8. }
  9.  
I was thinking it would be better if I create a class called Convert and create methods that override ToInt32. The method would simply do the try...catch above.

This is something new to me. What do you guys think?

Thanks,
Sam
Mar 25 '09 #1
0 984

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ovid | last post by:
Hi, I'm trying to determine the cleanest way to override class data in a subclass. class Universe { public String name; private static double PI = 3.1415; Universe(String name) {
3
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read...
0
by: Ian | last post by:
I've got this problem with overriding attributes on an inheritance chain where the XmlSerializer is concerned. For example: public class A { private string aWord = String.Empty(); public...
6
by: Bern McCarty | last post by:
I'm trying to use the VS 2005 March Tech Preview and am trying to adjust some MC++ to the new C++/CLI syntax. I got a little hung up when I encountered the below error. Certainly my...
2
by: Phuff | last post by:
I have an application that should run in the system tray while open. It is supposed to be open at all times and I need it to dissapear when the "X" button is pushed on the form...but without...
4
by: RSH | last post by:
How do I go about overriding a Control's OnPaint Method? I would like to prevent a control's color from changing when it is disabled. I have overridden the Form's OnPaint Method but I need to...
4
by: RSH | last post by:
I tried an implementation of overriding a ComboBox control. I am simply trying to avoid it repainting, but I can't seem to get it to work. What am I doing wrong? Please help. Thanks, Ron
1
by: jonpb | last post by:
Hi, I am extending a PictureBox. I have implemented overrides of OnResize and OnMouseMove that work as I expected, i.e. they handle the windows message sent by the system and calling base.OnResize...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.