Link to home
Start Free TrialLog in
Avatar of finance_teacher
finance_teacher

asked on

C# -- what is "strongly-typed" ?

What does "strongly-typed" mean ?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

it means that this is not allowed by the compiler:
string x = 1; 
while this works:
string x = "1";

Open in new window

angelIII is correct because in line 1, the value 1 is an integer not a string (the expected data type).
string x = "Hello";
x = "World";
x = 0.00; <-- This line would fail because 0.00 is a double.
 
However,
 
if you do:
x = 0.00.ToString(); <-- This line would work because the value is converted to a string first.

Open in new window

Well, I think of strongly-typed as being "intellisenseable". A DataTable that is strongly typed can have its fields named instead of indexed (dt.Rows.FirstName instead of dt.Rows["FirstName"]). Also, you can have a typo in the last case but not in the first case (without getting a compile error).
Gary Davis
ASKER CERTIFIED SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial