什么是5行代码(C#)中的错误,请帮忙 [英] What is Error in 5 line code (C#) please help
问题描述
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CoMicrosEditBox
{
public class CoMicrosEditBox: System.Windows.Forms.TextBox
{
{
private List<string> _ColumnHeading = new List<string>();
public List<string> ColumnHeading
{
set { _ColumnHeading = value; }
get { return _ColumnHeading; }
}
}
}
在另一个应用程序中使用此CoMicrosEditBox
时,不能为ColumnHeading
添加值.说System.String
没有构造函数.
但是,如果将字符串替换为int,则可以正常工作.
[edit]转义了<"和>"字符,使代码片段更有意义! -OriginalGriff [/edit]
While using this CoMicrosEditBox
in another application, cannot add values for ColumnHeading
. Saying System.String
doesn''t have contructor.
But if replace string with int, it is working fine.
[edit]''<'' and ''>'' characters escaped to make the code fragment more meaningfull! - OriginalGriff[/edit]
推荐答案
我刚刚尝试了您的代码(已针对错放的大括号进行了更正),并且可以编译并正常运行.也许您可以发布失败的实际代码片段,包括错误消息.
I have just tried your code (corrected for that misplaced open brace), and it compiles and runs fine. Perhaps you could post the actual snippet that fails, including the error message.
首先添加
First add
using System.Collections;
并将您的列表设为arraylist
Bcoz列表是通用的
如果要使用通用类型,请定义通用类型"T"
___________________________________________________
问候
纳库尔·昆德拉
(软件开发人员)
and make your list as arraylist
Bcoz list is a generic
if you want to use generic please define the generic type "T"
___________________________________________________
Regards
Nakul Kundra
(Software Developer)
第5行是:
Line 5 is:
using System.Windows.Forms;
里面没有错误.
There is no error in it.
这篇关于什么是5行代码(C#)中的错误,请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!