Parsing strings as numbers

- So far, I've dealt with string,…and number, data types.…Now, I'm going to talk about how to convert them,…taking a string, and turning it into a number.…I'll start, by declaring a string variable,…that I'll name, just s, for string.…I'll give it a value of 255.…String literals are always wrapped in double quotes.…Next, I'll declare an integer.…I'll name it, intFromString.…The process of turning a string into a number…is called parsing.…

Each of the .NET data type structures,…that represents one of the numeric values,…has a set of parse methods.…I'll use the Int32 class.…I'll call its Parse method,…and I'll pass in the string.…Then, I'll call my Output method.…I'll pass in a literal string…of "Value of intFromString",…and I'll append the variable.…I'll run the code.…By doing this, I'm actually turning this…back into a string.…

Let's try a mathematical operation on it,…to verify that I really have a number.…I'll create another integer variable,…that I'll call doubled.…I'll calculate the value by multiplying…intFromString by 2.…

Resume Transcript Auto-Scroll

Author

Released

1/18/2015

C# is an object-oriented language designed by Microsoft and used by systems engineers, desktop programmers, and mobile app developers the world over. In these tutorials, David Gassner takes you through C#'s history, its core syntax, and the fundamentals of writing strong C# code. After explaining C#'s relationship to .NET and Windows, David shows how to install Visual Studio, a great IDE for developing in C#, and then dives into the language itself. Along the way, he covers topics such as:

Declaring and initializing variables with a variety of data types

Exploring operators, expressions, constants, and enumerations

Controlling flow with conditional code and loops

Handling exceptions

Managing data collections

Creating custom classes

Organizing classes by namespace

Understanding inheritance

Whether you're choosing C# as your first step into programming or adding it your existing skillset, these training videos will help you understand the language and use it to build your own great software.

Skills covered in this course

Course Retiring Soon

C# Essential Training will be retired from the lynda.com library on June 15th, 2018. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out C# Essential Training: 1 Syntax and Object Oriented Programming in the lynda.com Online Training Library.

Continue Assessment

You started this assessment previously and didn't complete it. You can pick up where you left off, or start over.

Start My Free Month

Start your free month on LinkedIn Learning, which now features 100% of Lynda.com courses. Develop in-demand skills with access to thousands of expert-led courses on business, tech and creative topics.