What is the difference between these three ways to clear a Textbox?

前端 未结 10 691
孤城傲影
孤城傲影 2021-02-01 17:11

I am bit confused between the below three ways to clear the contents of a textbox. I am working with WPF and found All are working, but I am unable to find the difference.

10条回答
  •  名媛妹妹
    2021-02-01 17:49

    Some say String.Empty is faster than "" however String.EMpty is Static member that is initialized to ""

    When we call String.Empty the IL makes call to

    mscorlib.dll 
    
    IL_0007:  ldsfld     string [mscorlib]System.String::Empty
    

    Whereas for "" it does not

    IL_001a:  ldstr      ""
    

    SO logically it would make more sense that "" is more efficient than String.Empty

提交回复
热议问题