int.TryParse syntatic sugar

后端 未结 10 1409
广开言路
广开言路 2020-12-14 14:15

int.TryPrase is great and all, but there is only one problem...it takes at least two lines of code to use:

int intValue;
string stringValue = \"         


        
10条回答
  •  孤城傲影
    2020-12-14 14:52

    int val2 = "asd".AsInt(-1); 
    //Output : -1
     int val3 = "123".AsInt(-1); 
    //Output : 123
    

    You need to have System.Web.WebPages namespace.

提交回复
热议问题