English 中文(简体)
c#类
原标题:type casting issue in c#

D. 现在,问题在于检查过时的现时价值和类型......但正在出现错误......

方法:

    public static DateTime? ToNullableDateTime(string stringValue)
    {
        DateTime dateValue;
        if (DateTime.TryParse(stringValue, out dateValue)) { return dateValue; } 
     else {     return DateTime.MinValue; }
    }

a. 在我的物体类别中采用这种方法:

 Objects<DateTime?>.ToNullableDateTime(((Label)gvRow.FindControl("lblCommitmentDate")).Text);

原文:

不可含蓄地转换类型系统。 时间? 日期: 存在明确的转变(如果你没有 cast子?)

最佳回答

您重新界定了<代码>的回归类型?,并试图退回<代码>Datetime。

问题回答

暂无回答




相关问题
Delphi: generics and is -operator problem

Based on an earlier post, I ve written the following code. Please excuse the verbosity of this post. I believe it s better for all parties to have the full code available to test and comment on. ...

How to use argument in a cast with Delphi

How to do this in Delphi: procedure ToggleVisibility(ControlClass : TControlClass); var i : integer; begin for i := 0 to ComponentCount - 1 do if Components[i] is ControlClass then ...

Complicated C cast explanation

I m trying to figure out what the following code in C does? ((void(*)())buf)(); where buf is a char array.

Beginner: Extending a class in C#, am I doing it wrong?

Again disclaimer disclaimer still learning C# and OOP generally so I hope you ll be patient with me :) I am currently working with a CMS that has a class called FileVersion which basically contains a ...

Casting generic object array to two types

I ve got a method that receives an Object[] and then performs actions on that array. At first I was passing in this array as an IEnumerable<T> however the T can be of two different types. The ...

热门标签