Intro to computer programming HOW DO YOU DO CASTING CONVERSIONS? Simplest explanation possible please. Thank you
in what language?
@abtster like I'm an elementary school kid
In what programming language?
The answer depends on the programming language of choice
Ok let me try it for Python, because there it is simple If a variable contains a string, e.g. s = '10' and you need to have an it as an integer number (a number without a decimal point), you can do n = int(s) if you need is as a floating point (= a number with a decimal point) you can do f = float(s) then f will be 10.0 If you need n or f as strings, that can be don with s = str(n) Then s will be '10', in n was 10 s = str(f) Then s will be '10.0', if f was 10.0 Python has many functions (str(), int(), and float() are functions) you can use to change the type of an variable
@abtster oh, I'm using Visual Basics for this class. Does that make it a huge difference? And thank you by the way for helping me. It means a lot. Thanks
VB.Net? The idea is about the same. CType(variable, type), converts a variable to the type is a kind of general option But there are a whole range of more specific options Here is a short introduction: http://www.fmsinc.com/free/NewTips/NET/NETtip6.asp Here is a more advanced introduction http://msdn.microsoft.com/en-us/library/x53d8wxa.aspx Here is an overview: http://msdn.microsoft.com/en-us/library/s2dy91zy.aspx There are many examples there Hopefully this is of some use to you
Join our real-time social learning platform and learn together with your friends!