运行我的应用程序时收到以下错误:
<f:ajax> Unable to attach <f:ajax> to non-ClientBehaviorHolder parent
Run Code Online (Sandbox Code Playgroud)
我的JSF:
<h:commandButton id="submitschool" action="submit" value="Get templates" style="FONT-SIZE: medium;FONT-FAMILY: 'Rockwell';width : 128px; height : 24px;">
<ui:repeat value="#{person.theImage}" var="item">
<f:ajax event="change" render="image" />
<h:graphicImage id="image" value="#{item}"/>
</ui:repeat>
</h:commandButton>
Run Code Online (Sandbox Code Playgroud)
我正在尝试将数组中的元素返回到视图,其中"theImage"是person类中的数组.
我在Windows窗体应用程序中创建了一个Form1.cs,并且已经有一个Form1.resx文件.但每当我尝试运行我的应用程序时,我都会遇到以下错误:
无法为"....\gg\Form1.resx"创建清单资源名称.找不到文件'C:\ Documents and Settings\Administrator\Desktop\gg\Form1.cs'.
有谁能告诉我一个原因,我怎样才能克服我的问题?
我希望将两个字符串数组的内容组合成一个新列表,其中两个内容都连接在一起.
string[] days = { "Mon", "Tue", "Wed" };
string[] months = { "Jan", "Feb", "Mar" };
// I want the output to be a list with the contents
// "Mon Jan", "Mon Feb", "Mon Mar", "Tue Jan", "Tue Feb" etc...
Run Code Online (Sandbox Code Playgroud)
我该怎么做 ?当它只有两个数组时,以下工作并且很容易:
List<string> CombineWords(string[] wordsOne, string[] wordsTwo)
{
var combinedWords = new List<string>();
foreach (var wordOne in wordsOne)
{
foreach (string wordTwo in wordsTwo)
{
combinedWords.Add(wordOne + " " + wordTwo);
}
}
return combinedWords;
}
Run Code Online (Sandbox Code Playgroud)
但我希望能够传递不同数量的数组(即使用下面的签名方法)并使其仍然有效.
List<string> CombineWords(params …Run Code Online (Sandbox Code Playgroud) 如何使用带有OpenXML格式的 c#读取xls和xlsx文件而不使用OLEDB连接.我正在寻找Open XML格式程序.
下面是我使用OLEDB预处理的代码.但我正在寻找OpenXML格式.
public static DataTable ConvretExcelToDataTable(string FilePath)
{
string strConn = string.Empty;
if (FilePath.Trim().EndsWith(".xlsx"))
{
strConn = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", FilePath);
}
else if (FilePath.Trim().EndsWith(".xls"))
{
strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";", FilePath);
}
OleDbConnection conn = null;
OleDbCommand cmd = null;
OleDbDataAdapter da = null;
DataTable dt = new DataTable();
try
{
conn = new OleDbConnection(strConn);
conn.Open();
cmd = new OleDbCommand(@"SELECT * FROM [Sheet1$]", conn);
cmd.CommandType = CommandType.Text;
da = new OleDbDataAdapter(cmd); …Run Code Online (Sandbox Code Playgroud) 我有两个排序列表如下:
var list1 = new List<int>() { 1, 1, 1, 2, 3 };
var list2 = new List<int>() { 1, 1, 2, 2, 4 };
Run Code Online (Sandbox Code Playgroud)
我希望输出为: {1, 1, 2}
如何在C#中做到这一点?有没有办法使用Linq?
如果string为空或null,
不应该string.split(";")应该抛出错误?
对我来说,我正在尝试这个代码,并通过它没有任何错误,
string a = string.empty;
if (a.Split(';').Length - 1 < 1)
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我为什么它不会抛出错误以及为什么if语句为真.
我正在使用wpf窗口显示下一个项目列表与包装,我试图以WrapPanel这种方式使用:
<Grid>
<ItemsControl>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Items>
<Button Content="01" Height="30" Width="70"/>
<Button Content="02" Height="35" Width="72"/>
<Button Content="03" Height="20" Width="74"/>
<Button Content="04" Height="25" Width="76"/>
<Button Content="05" Height="18" Width="78"/>
<Button Content="06" Height="50" Width="70"/>
<Button Content="07" Height="40" Width="72"/>
<Button Content="08" Height="55" Width="74"/>
<Button Content="09" Height="45" Width="76"/>
<Button Content="10" Height="25" Width="78"/>
<Button Content="11" Height="20" Width="80"/>
<Button Content="12" Height="30" Width="70"/>
<Button Content="13" Height="45" Width="72"/>
<Button Content="14" Height="30" Width="74"/>
<Button Content="15" Height="20" Width="76"/>
<Button Content="16" Height="25" Width="78"/>
<Button Content="17" Height="35" Width="80"/> …Run Code Online (Sandbox Code Playgroud) 我有一个简单的洁净室这个可能的bug的例子.
static void Main(string[] args)
{
bool MyFalse = false;
if (MyFalse)
{
throw new Exception();
}
try
{
int i = 0;
}
catch (Exception e)
{
Console.Write(e);
}
Console.Read();
}
Run Code Online (Sandbox Code Playgroud)
如果在x64或AnyCPU中编译(当在VS2012中将32bit设置为false时),如果在if块中放置断点,则始终会命中它.
我们在VS2012,VS2010和VS2008中尝试了它们,当它们在64位编译时它们都触发了if块,但是在32位中它不会触发if块.
我们看了IL的32位和64位版本,它们看起来一样.
我们在生产代码中发现了这一点,因为if块正在运行并且抛出异常而不管布尔变量的值是什么,尽管在简单示例中我们似乎无法抛出异常,但它发生在生产代码中.
由于它发生在生产代码中,因此它不仅仅是调试器问题.
非常奇怪的行为,但似乎没有在if块中实际运行任何代码.假设这是他所看到的例外,开发商跳了起来.
(所有调试都处于调试模式 - 生产正在发布中)
如果抛出被注释掉 - 未达到if块.
我试图检测Print Screen按钮按下而窗体不是当前活动的应用程序.
如果可能的话怎么做?
我需要加密和解密大文件(~1GB).我尝试使用这个例子:http://www.codeproject.com/Articles/769741/Csharp-AES-bits-Encryption-Library-with-Salt 但我的问题是因为文件非常大,我得到outOfMemory异常.所以我需要用文件流替换内存流,我只是不知道该怎么做...
(添加我的代码:)
private static void AES_Encrypt(string srcFile, string encryptedFile, byte[] passwordBytes)
{
// Set your salt here, change it to meet your flavor:
// The salt bytes must be at least 8 bytes.
byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8};
FileStream fsInput = new FileStream(srcFile,
FileMode.Open,
FileAccess.Read);
FileStream fsEncrypted = new FileStream(encryptedFile,
FileMode.Create,
FileAccess.Write);
using (RijndaelManaged AES = new RijndaelManaged())
{
AES.KeySize = 256;
AES.BlockSize = 128;
var key …Run Code Online (Sandbox Code Playgroud)