小编Asa*_*sad的帖子

C#中bigint的等价物是什么?

我在处理C#中的值时应该使用什么,这对于SQL Server数据库来说是个bigint?

.net c# sql-server bigint

198
推荐指数
5
解决办法
20万
查看次数

将List <DerivedClass>转换为List <BaseClass>

虽然我们可以从基类/接口继承,但为什么我们不能声明List<> 使用相同的类/接口?

interface A
{ }

class B : A
{ }

class C : B
{ }

class Test
{
    static void Main(string[] args)
    {
        A a = new C(); // OK
        List<A> listOfA = new List<C>(); // compiler Error
    }
}
Run Code Online (Sandbox Code Playgroud)

有办法吗?

c# collections inheritance list covariance

162
推荐指数
7
解决办法
10万
查看次数

.NET中的"开放通用类型"究竟是什么?

我正在通过Asp.Net MVC课程并了解到,对于一种方法来确定控制器的动作,

  • 它必须没有"开放的通用类型"

我对某些泛型有所了解并在某种程度上使用它们,但是:

  • 什么是.Net中的开放泛型类型.
  • 是否存在封闭的泛型类型
  • 开放泛型类型是一个不经常使用的术语.与它混淆使用的是什么?

.net c# generics open-generics

114
推荐指数
4
解决办法
3万
查看次数

Visual Studio中的代码度量计算

以下代码指标计算的首选分数范围是多少?

  • 可维护性指数
  • 循环复杂性
  • 继承的深度
  • 班级耦合

c# maintainability cyclomatic-complexity code-metrics visual-studio-2008

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

37
推荐指数
8
解决办法
16万
查看次数

覆盖受保护的内部受保护!

这是一小时前提出的extension这个问题.

我们不能修改access modifiers重写一个时,virtual methodderived类.考虑命名空间中的ControlSystem.Web.UI

public class Control : IComponent, IDisposable,...
{ 
   protected internal virtual void CreateChildControls()
   { }
   .
   .
}
Run Code Online (Sandbox Code Playgroud)

现在考虑一下

public class someClass : System.Web.UI.Control
    { 
       // This should not compile but it does
        protected override void CreateChildControls()
        { }

       // This should compile but it does not
        protected internal override void CreateChildControls()
        { }  
    }
Run Code Online (Sandbox Code Playgroud)

任何机构可以解释一下吗?谢谢

c# virtual-functions

27
推荐指数
2
解决办法
9486
查看次数

为什么不能在结构体内初始化非静态字段?

考虑这个代码块:

struct Animal
{
    public string name = ""; // Error
    public static int weight = 20; // OK

    // initialize the non-static field here
    public void FuncToInitializeName()
    {
        name = ""; // Now correct
    }
}
Run Code Online (Sandbox Code Playgroud)
  • 为什么我们可以初始化static结构中的non-static字段而不是字段?
  • 为什么我们必须non-static在方法体中初始化?

.net c# struct field

20
推荐指数
1
解决办法
4079
查看次数

通过将控件的ID属性设置为"itemPlaceholder"来指定项占位符

我只有一个"Default.aspx"页面和一个ListView控件.为什么我收到此错误.从来没有发生过

"必须在ListView"ListView1上指定项目占位符.通过将控件的ID属性设置为"itemPlaceholder"来指定项目占位符.项目占位符控件还必须指定runat ="server"."

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TesterConcepts._Default"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>

        </div>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            onselecting="ObjectDataSource1_Selecting" SelectMethod="GetItemsCollection" 
            TypeName="TesterConcepts.CutomDataSource">
            <SelectParameters>
                <asp:Parameter Name="items" Type="Object" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1" 
            onselectedindexchanged="ListView1_SelectedIndexChanged">
        </asp:ListView>    
    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)

这样做甚至没有帮助

<asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1"
     OnSelectedIndexChanged="ListView1_SelectedIndexChanged"
        ItemPlaceholderID="PlaceHolder1">
</asp:ListView>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
Run Code Online (Sandbox Code Playgroud)

现在它抛出了这个异常

"必须在ListView'ListView1'上指定项占位符.通过将控件的ID属性设置为"PlaceHolder1"来指定项占位符.项占位符控件还必须指定runat ="server""

c# asp.net listview placeholder

13
推荐指数
3
解决办法
3万
查看次数

C#中的SQL Server唯一标识符等价物

我应该在C#中使用什么数据类型来使用SQL Server uniqueidentifier.

我需要任何转换等吗?

c# uniqueidentifier sql-server-2008

12
推荐指数
2
解决办法
2万
查看次数

Nullable <bool>类型有什么用?

一个布尔变量可以保持真或假,而布尔?也可以为空.

为什么我们需要bool的第三个值?如果它不是真的,它是什么,它是== false

你能建议一个我喜欢布尔的场景吗?代替.

谢谢

c# boolean nullable

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