28

This morning was going through a book where I found a paragraph as stated below :

Each data field in a table is a strongly typed data member, fully compliant with .NET’s Common Type System.

Does the above lines means " that objects written in different languages can interact with each other like "

And if it means the above lines what does exactly the above line means by saying different languages can interact with each other like

I am trying to work out with an example but no success till now.

Or is it something that i am missing and need to know. Please help me to understand.

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Tony
  • 1,177
  • 6
  • 18
  • 31

5 Answers5

23

For e.g you cannot Multiply or Divide two different types i.e String vs Integer

var answer = 1 * "1"; // you cannot do this

You have to explicity cast it, this is known as strongly typed

where as if you see in php

$x = "3" * 1; // is correct in php

So here you dont need to explicitly cast it.

FosterZ
  • 3,863
  • 6
  • 38
  • 62
17

When we say something is strongly typed we mean that the type of the object is known and available.

Let say I have a function like following

public int Add(int a, int b){
 return a+b;
}

We can call this function like

int result = Add(5,4);

But we can not do like following

int result = Add(5.2,4.5); // We will get here compilation error.

C# (and C++ and many other languages) is strongly typed because the compiler will detect and flag these errors at compilation time.

See here

Atish Kumar Dipongkor
  • 10,220
  • 9
  • 49
  • 77
  • Some would call this "statically typed", not strongly typed. Statically typed means the type of each object is 'statically' determined at compile time, and never changes. Some languages (e.g. Python) are strongly typed because they do not allow things like `print(1 + "1")` but you can change the type of a variable whenever you like. That makes Python "dynamically typed", which is the opposite of "statically typed". – Nic May 16 '17 at 04:19
4

No. It means that 1 and "1" (or any other number and string for that matter) are different values that cannot be casually interchanged in expressions.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
4

"fully compliant with .NET’s Common Type System" means that the data types are usable in any .NET language. So if you created a class that exposes a property in c# that is CTS compliant, that class can be consumed from say VB.net.

"Each data field in a table is a strongly typed data member" means that you can rely on the type of the value in the table, and you would have to cast it to another type if that was required. You can't do implicit casting.

user381624
  • 676
  • 1
  • 5
  • 21
0

This means, if there are two variables of different types, you have to cast them, to make an operation executable.

Else it will throw an exception.

Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154