小编Run*_*CMD的帖子

'Data.TimeLineChartedDay []'类型的对象无法转换为'Data.TimeLineChartedDay []'类型?

我在VS2008中遇到以下设计器错误:

 Object of type 'Data.TimeLineChartedDay[]' cannot be 
 converted to type 'Data.TimeLineChartedDay[]'.  
Run Code Online (Sandbox Code Playgroud)

???

public class TimeLineDisplay     
{
    private List<TimeLineChartedDay> chartedDays = new List<TimeLineChartedDay>();

    public List<TimeLineChartedDay> ChartedDays         
    {
        get { return chartedDays; }
        set { chartedDays = value;  }
    }
}

[Serializable]
public class TimeLineChartedDay
{
    private DateTime date;
    private int chartValue;

    public DateTime Date
    {
        get { return date; }
        set { date = value; }
    }

    public int ChartValue
    {
        get { return chartValue; }
        set { chartValue = value; …
Run Code Online (Sandbox Code Playgroud)

.net c# visual-studio

5
推荐指数
1
解决办法
3171
查看次数

C#.NET:if((e.State&ListViewItemStates.Selected)!= 0)< - 这是什么意思?

在标准的MSN代码中,ListView上有一行 - Ownerdraw - DrawItem:

if ((e.State & ListViewItemStates.Selected) != 0)
{
    //Draw the selected background
}
Run Code Online (Sandbox Code Playgroud)

显然它对状态进行了逐点比较?为什么按位?以下不起作用:

if (e.State == ListViewItemStates.Selected)
{
    //Doesn't work ??
}
Run Code Online (Sandbox Code Playgroud)

为什么这种比较不起作用?它只是一个标准的枚举?我有点困惑..

.net c# listview bit-manipulation

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

<92FB64J>是无效的XMLtag吗?

System.Xml.XmlException:名称不能以字符"9"开头,十六进制值0x39

这是因为标签不能以数字开头,或者这与xml编码有关

.net xml exception

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

CSV实际上是....分号分隔值...(在AZERTY上Excel导出)

我在这里有点困惑.

当我使用Excel 2003将工作表导出为CSV时,它实际上使用分号...

Col1;Col2;Col3
shfdh;dfhdsfhd;fdhsdfh
dgsgsd;hdfhd;hdsfhdfsh
Run Code Online (Sandbox Code Playgroud)

现在,当我使用Microsoft驱动程序读取csv时,它会使用逗号并将列表视为一个大列???

我怀疑Excel是用分号导出的,因为我有一个AZERTY键盘.但是,CSV读取器是否还必须考虑不同的分隔符?

我怎样才能知道合适的分隔符,和/或正确读取csv?

    public static DataSet ReadCsv(string fileName)
    {
        DataSet ds = new DataSet();
        string pathName = System.IO.Path.GetDirectoryName(fileName);
        string file = System.IO.Path.GetFileName(fileName);
        OleDbConnection excelConnection = new OleDbConnection
        (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + ";Extended Properties=Text;");
        try
        {
            OleDbCommand excelCommand = new OleDbCommand(@"SELECT * FROM " + file, excelConnection);
            OleDbDataAdapter excelAdapter = new OleDbDataAdapter(excelCommand);
            excelConnection.Open();
            excelAdapter.Fill(ds);
        }
        catch (Exception exc)
        {
            throw exc;
        }
        finally 
        {
            if(excelConnection.State != ConnectionState.Closed )
                excelConnection.Close();
        }
        return ds;
    } 
Run Code Online (Sandbox Code Playgroud)

.net c# csv excel

3
推荐指数
1
解决办法
8764
查看次数

没有唯一键的字典

我有Dictionary一些简单的string,string价值对.问题是,对于多个项目,有时密钥必须为空,这会产生字典错误 - >

 this key already exists.

还有另一课吗?

另外,我使用的是.NET 2.0,所以我不能使用Tuple类......

while (nav.MoveToNext())
{
    if (nav != null)
    {
        if (!String.IsNullOrEmpty(nav.Value))
        {
            if (nav.HasChildren)
            {
                navChildren = nav.Clone();
                navChildren.MoveToFirstChild();
                if (navChildren != null)
                    if (!veldenToSkip.Contains(nav.LocalName.Trim().ToLower())
                        && !nav.LocalName.StartsWith("opmerkingen_"))
                        itemTable.Add(nav.LocalName.Replace("_", " "), navChildren.Value);
                         //normal key and value
                while (navChildren.MoveToNext())
                {
                    if (!veldenToSkip.Contains(nav.LocalName.Trim().ToLower()))
                    {
                        if (navChildren != null)
                        {
                            if (!String.IsNullOrEmpty(navChildren.Value))
                            {
                                itemTable.Add("", navChildren.Value);
                                //Add blank keys
                            }
                        }
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我只想要这样的结构:

value1    value2
value3    value4 …
Run Code Online (Sandbox Code Playgroud)

.net c# generics

3
推荐指数
2
解决办法
3825
查看次数

私人字体和画笔是邪恶的吗?

我有一些将字体和画笔作为私有字段的类.有些东西说我这不是正确的做法,应该避免,但我不知道为什么....(Darn subconsiousness :-))

这是真的,为什么这是不好的做法?

class SomeControl: Panel
{
    private Font titelFont = new Font("Arial", 8.25f, FontStyle.Bold);        
    private SolidBrush whiteBrush = new SolidBrush(Color.White);


    public SomeControl()
    {
        //Do stuff
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# optimization gdi+

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

一个更好的Dispose方法(通过ComponentModel.IContainer ??)

我有这个我想改变的Dispose方法.(是的,我应该检查每个对象为null,我知道)

    protected override void Dispose(bool disposing)
    {
        if( disposing )
        {
            if( monthLineBrush != null)
                monthLineBrush.Dispose();
            monthHeaderLineBrush.Dispose();
            shadowBrush.Dispose();
            monthHeaderLineBrushDark.Dispose();
            monthFontBrush.Dispose();
            weekendBgBrush.Dispose();
            whiteBrush.Dispose();
            dayFontBrush.Dispose();
            chartBrush.Dispose();
            chartWarningBrush.Dispose();
            barBrush.Dispose();
            monthLinePen.Dispose();
            monthHeaderLinePen.Dispose();
            monthHeaderLinePenDark.Dispose();
            warningLinePen.Dispose();
            monthFont.Dispose();
            yearFont.Dispose();
            weekLinePen.Dispose();
            dayLinePen.Dispose();
            tooltip.Dispose();
            toolTipLabel.Dispose();
        }

        base.Dispose(disposing);
    }
Run Code Online (Sandbox Code Playgroud)

VS使用名为components的System.ComponentModel.IContainer对象,并仅处理此组件对象.然而,我找不到任何代码,其中不同的对象被添加到组件objedct?

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
Run Code Online (Sandbox Code Playgroud)

这是如何运作的 ?

.net c# memory

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

计算从时间跨度的总夜晚时间

假设夜间时间设定为20.30h至6.15h(AM).这两个参数是用户范围的变量.假设您的到达日期和出发日期可以从几分钟到一天以上.你如何计算夜晚的总小时数?

public static double CalculateTotalNightTimeHours(DateTime arrival, 
                                                  DateTime departure,
                                                  int nightTimeStartHour, 
                                                  int nightTimeStartMinute, 
                                                  int nightTimeEndHour, 
                                                  int nightTimeEndMinute)
{ 
    //??
}
Run Code Online (Sandbox Code Playgroud)

编辑:我明白这可能不是直接的肯定/没有答案,但也许有人有一个优雅的解决方案来解决这个问题.回答评论:我确实想要计算用户可编辑的夜间开始和结束时间之间的总小时数(或分钟数).我正在计算访问时间,第一个日期确实是到达参数.

我的代码是:

DateTime nightStart = new DateTime( departure.Year, departure.Month, departure.Day,
                                    nightTimeStartHour, nightTimeStartMinute, 0);
DateTime nightEnd = new DateTime( arrival.Year, arrival.Month, arrival.Day,
                                  nightTimeEndHour, nightTimeEndMinute, 0);
if (arrival < nightEnd)
{
    decimal totalHoursNight = (decimal)nightEnd.Subtract(arrival).TotalHours;
}
//...
Run Code Online (Sandbox Code Playgroud)

.net c# datetime timespan winforms

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

Microsoft.Web.UI.WebControls Treeview无法在某些计算机上呈现

我们有一个显示树视图的简单网页(Microsoft.Web.UI.WebControls)

正确渲染

现在,在某些机器上(主要是客户机;-))树视图未正确呈现:

没有正确呈现

我已经在我的所有机器上测试了这个,甚至是linux,所有内容都在这里正确呈现.我可以通过删除或重命名'webctrl_client'文件夹来重现此错误.

不过我不明白这个问题是什么?'webctrl_client'文件夹是否正确安装在根www文件夹中,.dll也正确放置?我尝试清除浏览器缓存但这似乎没有任何影响....

任何人都知道会发生什么事吗?

asp.net treeview web-controls

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

具有+100 MovieClip副本的AS3 CPU性能

我有一个简单的简单形状的动画片段.此影片剪辑会多次复制以创建图形效果.

随着副本数量的增加或动画片段的复杂性增加,CPU使用率也会上升.从90份副本开始,当我将鼠标移动到一个圆形的swf电影上时,播放停止(挂起).当鼠标移动停止时,swf再次继续在正确的位置,就像计算继续,但更新显示器没有.

现在这是一台四核电脑,我们是2010年......我无法相信或接受100 mc是可以渲染的最大动画片数......必须有更好的方法......

显而易见的问题是如何优化CPU性能?

我正在使用AS3,flash player 9. Movieclip是一个沿着1轴移动的simle矩形形状.

var myLinkage:Class = Class(getDefinitionByName(getQualifiedClassName(McToRepeat)));
var newMC:MovieClip = new myLinkage();
containerMC.addChild( newMC );
Run Code Online (Sandbox Code Playgroud)

flash cpu actionscript-3

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

为什么这个线程方法需要900毫秒才能完成?

private void Form1_Load(object sender, System.EventArgs e)
{
    StartToFillTree();
}

private void StartToFillTree( )
{
    try
    {
        tvFolders.Nodes.Clear();
        tvFolders.Nodes.Add( new TreeNode("Loading", -1, -1) );

        Thread explorerThread = new Thread( new ThreadStart( FillTreeInAnotherThread ) );
        explorerThread.Start();
    }
    catch (Exception exc)
    {
        //Do the catch
    }
}

private void FillTreeInAnotherThread()
{
    try
    {
        CreateTree(this.tvFolders);
    }
    catch (Exception exc)
    {
        //Do the catch
    }
}


public void ClearTreeview( TreeView tv ) 
{
    tv.Nodes.Clear();
}

public void AddNodeToTreeview( TreeView tv, TreeNode node ) 
{
    tv.Nodes.Add( …
Run Code Online (Sandbox Code Playgroud)

.net c# optimization multithreading

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

imageList.Draw不会绘制不同的大小?

ImageList有一个名为"Draw"的方法:

imageList.Draw(graphics, bounds.X, bounds.Y, bounds.Width, bounds.Height, imgIndex);
Run Code Online (Sandbox Code Playgroud)

我使用此方法在PrintDocument的图形对象上绘制图像.使用原始图像尺寸(16 x 16像素)时,图像绘制正确.但是,如果我更改边界大小,则不会绘制任何内容.即使将尺寸更改为32 x 32(双倍尺寸)也无效.什么都没画.我需要改变绘制的大小,因为dpi不同......我在哪里错了?

编辑:解决方案似乎只是使用g.DrawImage方法.为什么imageList.Draw()不绘制仍然是我的一个谜...

g.DrawImage(imageList.Images[imgIndex], bounds);
Run Code Online (Sandbox Code Playgroud)

.net c# graphics gdi+ imagelist

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

在调试模式下反序列化?

谁能解释为什么会发生以下情况:

当我们在调试模式下序列化一个文件时,我们可以在调试模式下再次打开它,但不能在运行时打开它。当我们在运行时模式下序列化一个文件时,我们可以在运行时模式下再次打开它,但不能在调试模式下打开它。

现在我知道你会说:那是因为他们有不同的程序集。但是我们使用自定义 Binder,如下所示......此外,如果我们比较两种类型,“bool same = (o.GetType() == c.GetType())”,我们总是得到“true”作为结果? ??

那为什么我们打不开文件呢?

public class Binder : SerializationBinder {

    public override Type BindToType(string assemblyName, string typeName) {
        Type tyType = null;
        string sShortAssemblyName = assemblyName.Split(',')[0];
        Assembly[] ayAssemblies = AppDomain.CurrentDomain.GetAssemblies();
        if (sShortAssemblyName.ToLower() == "debugName")
        {
            sShortAssemblyName = "runtimeName";
        }
        foreach (Assembly ayAssembly in ayAssemblies) {
            if (sShortAssemblyName == ayAssembly.FullName.Split(',')[0]) {
                tyType = ayAssembly.GetType(typeName);
                break;
            }
        }
        return tyType;
    }
}



    public static DocumentClass Read(string fullFilePath, bool useSimpleFormat)
    {
        DocumentClass c = new DocumentClass(); …
Run Code Online (Sandbox Code Playgroud)

c# debugging serialization mode

0
推荐指数
1
解决办法
680
查看次数