相关疑难解决方法(0)

TypeCasting的表现

两者之间是否有任何可测量的性能差异

((TypeA) obj).method1();
((TypeA) obj).method2();
((TypeA) obj).method3();
Run Code Online (Sandbox Code Playgroud)

var A = (TypeA) obj;
A.method1();
A.method2();
A.method3();
Run Code Online (Sandbox Code Playgroud)

什么时候使用?

我经常看到类似的东西

if (((TextBox)sender).Text.Contains('.') || ((TextBox)sender).Text.Contains(','))
Run Code Online (Sandbox Code Playgroud)

并想知道这是否是对性能的浪费.

.net c# performance types

62
推荐指数
2
解决办法
7313
查看次数

标签 统计

.net ×1

c# ×1

performance ×1

types ×1