我正在尝试构建一个用户控件来显示Dictionary的内容
问题是我不知道用户控件中的键和值的类型,我知道在我创建用户控件时,但C#似乎不想让我创建一个通用的用户控件,让我我将它们传递给托管字典
即
public class MyCtrl<TKey,TValue> : UserControl
{
private Dictionary<TKey,TValue>
}
Run Code Online (Sandbox Code Playgroud)
因为它引用了.\ Obj\Debug\MyCtrl.gics中的生成文件是只读的
向我展示的唯一解决方案是从头开始创建类,而不是让设计人员处理任何格式化是否有更好的可能性?
为了在我的代码中提供大约8-10个地方的一些背景,我需要用户填充值的字典,而不是构建8-10个控件,这些控件都完全相同但具有不同的类型(实际上很多时候)唯一的区别是哪个枚举作为关键)我想要一个控件来处理这个问题
我正在寻找一些建议.
我正在编写一个类来自动从C#中的excel电子表格(使用NPOI api)中提取信息,然后将此信息导入数据库.除了一个小问题,我已经完成了所有工作.
我正在使用的其中一个电子表格包含以下格式的日期:04/01/2011 04:43:28.
当我运行Web应用程序时,我收到以下错误消息:
字符串未被识别为有效的DateTime
所以我在此之后通过代码进行了调试,事实证明日期正在读入:40546.0151388889,因此它被格式化为一个数字.
我不确定如何克服这个问题,我希望有人能指出我正确的方向?
这是我的代码中的一个exerpt:
using (FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read))
{
HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs);
HSSFSheet sheet = templateWorkbook.GetSheetAt(w);
HSSFRow row = null;
for (int i = 1; i <= sheet.LastRowNum; i++)
{
FTPSalesDetails t = null;
int currentColumn = 0;
try
{
ModelContainer ctn = new ModelContainer();
row = sheet.GetRow(i);
if (row == null)
{
continue;
}
t = new FTPSalesDetails
{
RowNumber = i,
InvoiceDate = …Run Code Online (Sandbox Code Playgroud) 我正在调试一些代码,需要找出
DoCmd.TransferSpreadsheet acImport, , ".....
失败的地方,所以我决定逐行"手动"导入它以查看它的位置.
我想这样的东西就是我要找的东西:
mySpreadSheet = ConnectTo(Spreadsheet.xlsx)
while(!mySpreadSheet.EOF)
get(mySpreadSheet.nextLine)
SQL("UPDATE MyTable with mySpreadSheet.nextLine")
Run Code Online (Sandbox Code Playgroud)
我试过谷歌搜索无济于事.任何帮助深表感谢!
附加信息:
我在大学使用CS106库.用Visual Studio 2010更改Visual Studio 2008后,我在构建新项目或旧项目方面遇到了问题.我认为新的Visual Studio与CS106库不兼容.任何人都可以告诉我如何解决这个问题.问题?
这是输出:
1>------ Build started: Project: Blank, Configuration: Debug Win32 ------
1>Build started 3/15/2011 2:03:21 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Blank.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) referenced in function "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned int,unsigned …
我使用这个向量:vector<string, vector<int>>.我认为第一次迭代返回一个数组:
for (vector<string, vector<int>>::iterator it = sth.begin(); it != sth.end(); ++it) {
// how do I get the string?
// I tried (*it)[0], but that did not work
}
Run Code Online (Sandbox Code Playgroud)
另外,我怎么会push_back这个向量?传球vector<string, vector<int>()>()对我不起作用.谢谢
我知道我可以在Perl中有条件地使用模块但是"pragma"呢?我的测试表明,use bigint在Perl 中可能比普通数学慢得多,我只需要它来处理64位整数,所以我只想在Perl没有用64位整数支持构建时使用它,我也知道如何检查是否使用该Config模块.
我尝试了各种各样的东西eval和BEGIN块,但无法找到有条件使用bigint的方法.我知道我可以使用Math::BigInt但是我不能为bigint和64位情况使用单个代码路径.
我有Dropdownlist,其值字段和文本字段在运行时绑定.它具有--select--值为的第一项,0
其余值在运行时绑定.
我已经给validaton组对照和验证的"g1"
和Intialvalue=0
但即使我选择了--select--选项,页面仍会回发.
<asp:DropDownList AutoPostBack="true" CssClass="dropdown" ValidationGroup="g1"
ID="ddlReportType" runat="server"
OnSelectedIndexChanged="ddlReportType_SelectedIndexChanged"></asp:DropDownList>
<asp:RequiredFieldValidator ControlToValidate="ddlReportType" ID="RequiredFieldValidator1"
ValidationGroup="g1" CssClass="errormesg" ErrorMessage="Please select a type"
InitialValue="0" runat="server" Display="Dynamic">
</asp:RequiredFieldValidator>
Run Code Online (Sandbox Code Playgroud)
和代码背后绑定下拉列表
ddlReportType.Items.Clear();
ddlReportType.DataSource = dt.Tables[0];
ddlReportType.DataTextField = "ReportType";
ddlReportType.DataValueField = "ReportTypeID";
ddlReportType.DataBind();
ddlReportType.Items.Insert(0, new ListItem("--Select--", "0"));
//ddlReportType.Items[0].Value = "0";
ddlReportType.SelectedIndex = 0;
Run Code Online (Sandbox Code Playgroud) 我是PHPUnit的初学者.
这是我创建的示例测试类:
class NewTest extends PHPUnit_Framework_TestCase
{
protected $foo;
function testFirst ()
{
$this->foo = true;
$this->assertTrue($this->foo);
}
/**
* @depends testFirst
*/
function testSecond ()
{
$this->assertTrue($this->foo);
}
}
Run Code Online (Sandbox Code Playgroud)
执行testSecond时,会抛出错误" Undefined property NewTest::$foo".
为什么会这样?每次测试执行后,PHPUnit都会清除新属性吗?有没有办法在测试中设置属性,以便在同一测试类的其他测试中可以访问它?
我正在尝试创建一个能够运行各种Powershell脚本的Windows应用程序.
我有一个脚本,它应该工作(从Powershell提示符运行时),我的Windows应用程序似乎执行它应该,但它无法在我的OU上找到方法.
当我从Windows应用程序执行脚本时,我收到这些消息:
错误:检索成员"创建"时发生以下异常:"服务器上没有此类对象."
错误:检索成员"删除"时发生以下异常:"服务器上没有此类对象."
Powershell脚本:
function New-AdUser {
param (
[string] $Username = $(throw "Parameter -Username [System.String] is required."),
[string] $Password = $(throw "Parameter -Password [System.String] is required."),
[string] $OrganizationalUnit = "Users",
[string] $DisplayName,
[string] $FirstName,
[string] $LastName,
[string] $Initials,
[string] $MobilePhone,
[string] $Description,
[switch] $CannotChangePassword,
[switch] $PasswordNeverExpires,
[switch] $Disabled
)
try {
$currentDomain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$dn = $currentDomain.GetDirectoryEntry().distinguishedName
$ou = [ADSI] "LDAP://CN=$OrganizationalUnit,$dn"
$userAccount = $ou.Create("user", "cn=$Username")
$userAccount.SetInfo()
$userAccount.userAccountControl = ($userAccount.userAccountControl.Item(0) -bxor 0x0002) #Enable the account
$userAccount.SetInfo()
$userAccount.sAMAccountName = …Run Code Online (Sandbox Code Playgroud) 我创建一个通用的处理程序(ashx),但我想在我的代码中添加区域,如下所示
#region MyRegionName
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
#endregion
Run Code Online (Sandbox Code Playgroud)
没有错误,但没有扩展和崩溃的问题.
请问任何建议?注意:我正在使用visual studio 2010
c# ×4
asp.net ×3
excel ×2
biginteger ×1
c++ ×1
conditional ×1
datetime ×1
excel-2010 ×1
generics ×1
httphandler ×1
ms-access ×1
perl ×1
php ×1
phpunit ×1
powershell ×1
properties ×1
testing ×1
vba ×1
vector ×1
wpf ×1