Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Object-Oriented Programming Types

doubt,int,sting are example of

what kind example are doubt,int,sting

2 Answers

Steven Parker
Steven Parker
229,670 Points

The terms "double", "int", and "string" are all types.

I'm assuming you meant to write "double" instead of "doubt", and "string" not "sting". :smirk:

Doubles, Integers and Strings all are datatypes, they descripe the "type" of data which a variable holds / is going to hold. If I am correct: The keyword "var" defines a variable with a first-dynamic datatype that gets set once the variable starts holding data. To me experience when taking userInput variables it is always good practice to not define the type first, unless you only want a specific thing to be entered.

Steven Parker
Steven Parker
229,670 Points

Other languages might use "var" as you describe, but in C# an implicitly typed local variable is strongly typed just as if you had declared the type yourself, but the compiler determines the type. For example, the following two declarations of "i "are functionally equivalent:

var i = 10; // Implicitly typed. 
int i = 10; // Explicitly typed.