Click here to Skip to main content
15,917,795 members
Home / Discussions / C#
   

C#

 
AnswerRe: Serialization Pin
Cracked-Down19-Mar-09 1:23
Cracked-Down19-Mar-09 1:23 
GeneralRe: Serialization Pin
Paul Unsworth19-Mar-09 1:27
Paul Unsworth19-Mar-09 1:27 
GeneralRe: Serialization Pin
Cracked-Down19-Mar-09 2:10
Cracked-Down19-Mar-09 2:10 
QuestionEncrypt bitmap image for C# Windows application [modified] Pin
nudma19-Mar-09 0:59
nudma19-Mar-09 0:59 
AnswerRe: Encrypt bitmap image for C# Windows application Pin
Michael Bookatz19-Mar-09 1:17
Michael Bookatz19-Mar-09 1:17 
AnswerRe: Encrypt bitmap image for C# Windows application Pin
Henry Minute19-Mar-09 6:23
Henry Minute19-Mar-09 6:23 
GeneralRe: Encrypt bitmap image for C# Windows application Pin
nudma19-Mar-09 7:13
nudma19-Mar-09 7:13 
GeneralRe: Encrypt bitmap image for C# Windows application Pin
Henry Minute19-Mar-09 7:31
Henry Minute19-Mar-09 7:31 
GeneralRe: Encrypt bitmap image for C# Windows application Pin
nudma24-Mar-09 6:42
nudma24-Mar-09 6:42 
QuestionString to int Pin
mrithula818-Mar-09 23:47
mrithula818-Mar-09 23:47 
AnswerRe: String to int Pin
musefan18-Mar-09 23:50
musefan18-Mar-09 23:50 
GeneralRe: String to int Pin
Michael Bookatz19-Mar-09 0:54
Michael Bookatz19-Mar-09 0:54 
GeneralRe: String to int Pin
Mohammad Dayyan19-Mar-09 1:03
Mohammad Dayyan19-Mar-09 1:03 
GeneralRe: String to int Pin
musefan19-Mar-09 1:08
musefan19-Mar-09 1:08 
GeneralRe: String to int Pin
Michael Bookatz19-Mar-09 1:14
Michael Bookatz19-Mar-09 1:14 
GeneralRe: String to int Pin
DaveyM6919-Mar-09 2:09
professionalDaveyM6919-Mar-09 2:09 
GeneralRe: String to int Pin
musefan19-Mar-09 2:15
musefan19-Mar-09 2:15 
GeneralRe: String to int Pin
Mirko198019-Mar-09 1:11
Mirko198019-Mar-09 1:11 
GeneralRe: String to int Pin
Michael Bookatz19-Mar-09 1:16
Michael Bookatz19-Mar-09 1:16 
GeneralRe: String to int Pin
Mirko198019-Mar-09 1:36
Mirko198019-Mar-09 1:36 
GeneralRe: String to int Pin
Michael Bookatz19-Mar-09 2:11
Michael Bookatz19-Mar-09 2:11 
GeneralRe: String to int Pin
DaveyM6919-Mar-09 2:11
professionalDaveyM6919-Mar-09 2:11 
AnswerRe: String to int Pin
DaveyM6919-Mar-09 0:18
professionalDaveyM6919-Mar-09 0:18 
musefan has given you the perfect answer. Just be aware that if the number can't be converted to an int you will get zero.

I have an extension method that I use when working with text/xml etc files to simplify stuff.
public static class ExtensionMethods
{
    /// <summary>
    /// Converts a string to an integer.
    /// </summary>
    /// <param name="value">The string to convert.</param>
    /// <returns>The integer value of the string if valid; otherwise, zero.</returns>
    public static Int32 ToInt32(this string value)
    {
        int result;
        Int32.TryParse(value, out result);
        return result;
    }
}
Now I can can just use something like
int intFromFile = stringFromFile.ToInt32();


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

GeneralRe: String to int Pin
Greg Chelstowski19-Mar-09 0:57
Greg Chelstowski19-Mar-09 0:57 
GeneralRe: String to int Pin
DaveyM6919-Mar-09 2:18
professionalDaveyM6919-Mar-09 2:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.