?
Solved

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

Posted on 2009-07-10
4
Medium Priority
?
782 Views
Last Modified: 2012-05-07
What does "strongly-typed" mean ?
0
Comment
Question by:finance_teacher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24827685
it means that this is not allowed by the compiler:
string x = 1; 
while this works:
string x = "1";

Open in new window

0
 
LVL 8

Expert Comment

by:RyanAndres
ID: 24827882
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

0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 24828227
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
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 2000 total points
ID: 24833047
I think of "strongly typed" as opposed to loosely typed.

Strong typing is often used in the same context as static typing. It means the compiler guarantees, through a strong type system, and compile time checking, that a variable will not be used at runtime in some unknown / unsupported way. You can guarantee not to have a runtime type conversion error or exception.

This differs from languages like Perl and Ruby where a type goes with the value, and depending on the value in a variable at any given time, the operations and conversions no that variable may change.

Languages like Perl do not even allow you to specifically create a typed variable (or not easily) but they are all treated as scalars or variants.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question