小编New*_*101的帖子

无法将"System.Random"类型的对象强制转换为"System.IConvertible"类型

我正在使用Random函数编写一个小的Heads或Tails程序,并接收一个Unable来强制转换'System.Random'类型的对象来输入'System.IConvertible'消息,我不知道为什么.有人可以轻松一点.谢谢.

protected void Button1_Click(object sender, EventArgs e)
{
    Random rNum = new Random();
    rNum.Next(2, 47);


    int rrNum = Convert.ToInt32(rNum);

    string result;
    result = (rrNum % 2 == 0) ? "Heads" : "Tails";
    lblResult.Text = result;

}
Run Code Online (Sandbox Code Playgroud)

.net c#

7
推荐指数
1
解决办法
4807
查看次数

嵌套XML XSL for-each循环

我无法读出我的嵌套for-each循环.出于某种原因,它不会在直接节点下循环.麻烦似乎与tages.My第一循环发生后,我打开表,并通过全表的管理报告和嵌套在它下面的第二点我循环.这工作正常,但是当我在下面嵌套其他节点时,我能够提取值,但不是特定于父节点.这次演习中我的眼睛充满了血丝,有人可以提供一些帮助.提前致谢.

XSL:

    <tr bgcolor="9acd32">
    <table><th>Data Source Name:</th></table>
    <table><th><xsl:value-of select="@Value"/>   </th></table>
    </tr>
    <tr> 
   <xsl:for-each select="*[name()='PartInformation']">  
       <table bgcolor="#99ff66"><th>Part Information:</th></table>
       <table bgcolor="#99ff66"><th><xsl:value-of select="@Value"/></th></table>       
   <tr> 
    <xsl:for-each select="*/*[name()='InspPrgInformation']">    
       <table bgcolor="#33ccff"><th>Inspection Program ID:</th></table>
       <table bgcolor="#33ccff"><th><xsl:value-of select="@Value"/></th></table>
    <table bgcolor="#33ccff"><th><xsl:value-of select="@NoOfTracefields"/></th></table>
    </xsl:for-each>
    </tr>
    </xsl:for-each>
    </tr>         
<tr> 
   <xsl:for-each select="*/*/*[name()='AreaInformation']">    
       <table bgcolor="#FFFF99"><th>Area Information:</th></table>
       <table bgcolor="#FFFF99"><th><xsl:value-of select="@Area"/></th></table>
       <table bgcolor="#FFFF99"><th><xsl:value-ofselect="@AreaCount"/>         
  </th></table>
   </xsl:for-each>
   </tr>

 </xsl:for-each>
</table>
</center>
Run Code Online (Sandbox Code Playgroud)

XML:

 <AdminReports xmlns="30/11/2011 09:25:58">

  <AdminReport ID="1">
    <DataSourceInformation DataSourceID="2" Value="DCS_AERO_KINSTON_DCS350">
      <PartInformation PartID="8" Value="WithAreaInfo">
        <InspPrgInformation InspPrgID="10" Value="DCS350_Sec15Drill_Pannel1WithInfo"       NoOfTracefields="1">          
          <AreaInformation Area="L3" AreaCount="59"/>
          <AreaInformation Area="L4" AreaCount="45"/>
          <AreaInformation Area="LT4" AreaCount="54"/>
        </InspPrgInformation> …
Run Code Online (Sandbox Code Playgroud)

xml xslt

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net ×1

c# ×1

xml ×1

xslt ×1