English 中文(简体)
C# 图对var有约束力
原标题:C# Chart bind to var

我从林吉问到这个结构:

    [0] = { Type = "K", Count = 1 }
    [1] = { Type = "Z", Count = 8 }

我现在想把它与我的图表联系起来(不要说)。 我试图这样做:

    series1.Points.DataBindXY(t. ????, t.????);

but I don t know how to get "first column" and "second column" of my var. Please help

Edit: My linq query:

                var t= (from oAction in Actions
                    group oAction by oAction.Type.Name into g
                    select new { Type = g.Key, Count = g.Count() }).ToArray();
问题回答

我从未与协会合作。 净图表,因此我不敢肯定会这样做,但我认为它应当:

series1.Points.DataBindXY(t.Select(x => x.Type), t.Select(x => x.Count));

这份名单将汇出<代码>。 类型值为<代码>的x值和收集值>。

var t= (from oAction in Actions
                    group oAction by oAction.Type.Name into g
                    select new { Type = g.Key, Count = g.Count() }).ToArray();

不管怎样,你都会回到“匿名”一类。 你可以肯定地获得t.Type或t.Count,但是,只有确定该准则调查的方法,才能捕获。 匿名类型的范围限于定义的方法。 可以通过使用“动力”关键词来克服这一限制。 但是,我没有尝试这样做,这样肯定会达到100%。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签