Solved

Converting value from String to Int in a Property

Posted on 2007-11-16
6
188 Views
Last Modified: 2013-12-17
       public string RunIDProperty
        {
            get
            {
                return this.RunID;
            }
            set
            {
                int intRunID;
                intRunID = (int) value;  <--This is where I am trying to convert types, but is says I can't implicitly convert type 'string' to 'int'      

                if (value != "" && (intRunID >= 0 && intRunID <= 50))
                {
                    this.RunID = value;
                }
            }
        }

Thanks in advance!
0
Comment
Question by:indy500fan
  • 3
  • 2
6 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
Comment Utility
try with this:

    set

    {

         int intRunID;

         if (int.TryParse(value, out intRunID)

         {

                if (intRunID >= 0 && intRunID <= 50)

                       this.RunID = intRunID;

         }

    } 

Open in new window

0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 500 total points
Comment Utility
a little typo, missing parenthesis. Should be:

         if (int.TryParse(value, out intRunID))
0
 
LVL 22

Expert Comment

by:p_davis
Comment Utility
or
Convert.ToInt32(value)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
Convert.ToInt32() will generate an exception if string is not a perfect number.
That's why I don't use int.Parse() instead of int.TyryParse()
0
 

Author Comment

by:indy500fan
Comment Utility
jaime,

That worked!  Thank you!

Regards,
Eric
0
 

Author Closing Comment

by:indy500fan
Comment Utility
Excellenet!!!!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now