What does strongly typed means in .NET framework?

后端 未结 5 2251
悲哀的现实
悲哀的现实 2020-12-28 15:11

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 wit

5条回答
  •  独厮守ぢ
    2020-12-28 15:55

    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

提交回复
热议问题