我正在为我兄弟的公司建立一个网站.网站上最重要的元素是邮件功能.访问者可以使用该系统向我的兄弟发送电子邮件,这一点非常重要.所以我使用了这段代码:
message.From = new MailAddress("someemail@somedomain.com");
message.To.Add(new MailAddress("emailaddress"));
message.CC.Add(new MailAddress("emailaddress"));
SmtpClient client = new SmtpClient("smtp.live.com", 587);
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("emailaddress","password");
client.Send(message);
Run Code Online (Sandbox Code Playgroud)
代码工作正常,但有一个问题:我需要填写我的密码,我不想这样做.有没有办法使用MD5哈希(或其他一些加密)或其他东西来保护我的密码?
我刚刚从SQL服务器更改为SQLite,一切都很顺利,一切都运行正常,唯一困扰我的是我收到一条警告,指出与SQLite引用不匹配,警告信息下方:
警告1正在构建的项目的处理器体系结构"MSIL"与参考"System.Data.SQLite,Version = 1.0.84.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139,processorArchitecture = x86"的处理器体系结构不匹配,"x86".这种不匹配可能会导致运行时故障.请考虑通过Configuration Manager更改项目的目标处理器体系结构,以便在项目和引用之间调整处理器体系结构,或者依赖于具有与项目的目标处理器体系结构相匹配的处理器体系结构的引用.LivePigeonClient
我安装了错误的参考吗?或者我真的需要将我的应用程序的目标设置为x86吗?因为那不是我想要的,有没有人有什么建议去做什么,摆脱这个警告?
谢谢你的时间!
我想所有的SubItems我的MenuStrip,所以我可以一次改变它们.
我正在尝试以下内容,但它们不起作用:
foreach (ToolStripMenuItem toolItem in menuStrip1.DropDownItems)
{
//Do something with toolItem here
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我编写一个有利于从中foreach loop获取所有数据的好处吗?SubMenuItems(DropDownItems)MenuStrip
编辑现在尝试使用以下内容Recursive method:
private void SetToolStripItems(ToolStripItemCollection dropDownItems)
{
try
{
foreach (object obj in dropDownItems)
{
if (obj.GetType().Equals(typeof(ToolStripMenuItem)))
{
ToolStripMenuItem subMenu = (ToolStripMenuItem)obj;
if (subMenu.HasDropDownItems)
{
SetToolStripItems(subMenu.DropDownItems);
}
else
{
}
}
}
}
catch
{
}
}
Run Code Online (Sandbox Code Playgroud) 我在 WPF 中使用 Ribbon 控件,我注意到有 2 个不同的版本。
使用 Microsoft.Windows.Controls.Ribbon;
使用 System.Windows.Controls.Ribbon;
当我同时使用它们时。有了这个:
<ribbon:RibbonWindow x:Class="WPSDashboard.Views.ShellWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism"
Title="WPSDashboard"
x:Name="RibbonWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Ribbon Region -->
<r:Ribbon x:Name="Ribbon" prism:RegionManager.RegionName="RibbonRegion">
<r:Ribbon.ApplicationMenu>
<r:RibbonApplicationMenu SmallImageSource="Images\SmallIcon.png">
<r:RibbonApplicationMenuItem Header="Exit"
x:Name="MenuItemExit"
ImageSource="Images\Exit.png"
Command="{Binding ExitCommand}"/>
</r:RibbonApplicationMenu>
</r:Ribbon.ApplicationMenu>
</r:Ribbon>
<Grid x:Name="ClientArea" Grid.Row="1">
<!-- Workspace Region-->
<GridSplitter HorizontalAlignment="Left" Width="2" Grid.Column="1"/>
<ContentControl x:Name="WorkspaceRegion" Grid.Column="1" prism:RegionManager.RegionName="WorkspaceRegion" />
</Grid>
</Grid>
</ribbon:RibbonWindow>
Run Code Online (Sandbox Code Playgroud)
我的 Ribbontabs 将加载,但窗口现在看起来像这样:我无法单击关闭并最小化和最大化。<---

我怎样才能让边框变得正常而不是小? …
I have to write function in C# which will surround every word with double quotes. I want it to look like this:
"Its" "Suposed" "To" "Be" "Like" "This"
Run Code Online (Sandbox Code Playgroud)
Here is the code I've come up with so far, but its not working:
protected void btnSend_Click(object sender, EventArgs e)
{
string[] words = txtText.Text.Split(' ');
foreach (string word in words)
{
string test = word.Replace(word, '"' + word + '"');
}
lblText.Text = words.ToString();
}
Run Code Online (Sandbox Code Playgroud)
我正在使用visual studio 2013,visual basic,windows Forms处理excel文件.
如何将widthb 的列更改为30?
我不需要使用autofit,因为它使文本变小以适应单元格的默认宽度.
xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlBook = xlApp.Workbooks.Open(FileName)
SheetReport = CType(xlBook.Sheets.Add(), Excel.Worksheet)
SheetReport.Name = "Report"
SheetReport.Range("B2").Value = "Agent Name"
' need resize column b
Run Code Online (Sandbox Code Playgroud) 我希望能够做到这样的事情:
class A<T1, T2>
{
public void Call(T1 arg1, T2 arg2)
{
B b = new B();
b.DoSomething(arg1); // determine which overload to use based on T1
b.DoSomething(arg2); // and T2
}
}
class B
{
public void DoSomething(int x)
{
// ...
}
public void DoSomething(float x)
{
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
我知道可以使用if/else检查来完成,但这似乎并不优雅,特别是当我有20多种类型可供选择时.
为什么我不能创建两个重载方法,其参数既是数组列表,又有不同的数据类型?
public class test {
public static void main(String[] args){
ArrayList<Integer> ints = new ArrayList<Integer>();
ints.add(1);
ints.add(2);
ints.add(3);
ints.add(4);
ints.add(5);
showFirst(ints);
ArrayList<Double> dubs = new ArrayList<Double>();
dubs.add(1.1);
dubs.add(2.2);
dubs.add(3.3);
dubs.add(4.4);
dubs.add(5.5);
showFirst(dubs);
}
public static void showFirst(ArrayList<Integer> a)
{
System.out.println(a.remove(0));
}
public static void showFirst(ArrayList<Double> a)
{
System.out.println(a.remove(0));
}
}
Run Code Online (Sandbox Code Playgroud)
我在eclipse中,它强调了导致代码为红色的问题并给出了这样的信息: Method showFirst(ArrayList<Integer>) has the same erasure showFirst(ArrayList<E>) as another method in type test
我能让它工作的唯一方法是添加其他参数,例如, int bafter showFirst(ArrayList<Integer> a和, int bafter showFirst(ArrayList<Double> a.
有没有办法让这段代码按照我的意图运作?如果没有,我想知道为什么会这样. …
我在Visual Basic(2013)中遇到这个奇怪的问题。我在MDI容器中有一个表单。他们两人,有属性WindowState来Maximized。执行时,MDI容器以最大化状态加载(到目前为止,确定!)。但是,当我打开子窗体时,它不会显示“实际最大化”状态(尽管右上角的“还原”按钮显示它已以最大化状态加载,但未最大化)。
我什至尝试 form1.WindowState = FormWindowState.Maximized之前和之后form1.Show(),但没有运气。
我也附上了截图。请注意MDI容器的死空间和子窗体的Restore图标(这意味着子窗体处于最大化状态)。

观察很少-
当我还原然后再次最大化它时,它确实可以正确地最大化。
我还观察到此问题仅发生一次。我的意思是,如果我将两个表单都设置为以最大化状态加载。当我打开第一个窗体(无论是哪个窗体)时,它的加载方式与屏幕截图中显示的一样,之后,当我打开第二个窗体时,它将以最大化状态加载。
我不知道是怎么了?如何纠正呢?
PHP的新手,我正在努力实现某些目标,在我看来,这可以在c#中轻松完成.但是在PHP中,对我来说并不容易实现.
迭代XML文件时,我想存储每年的所有平均分数.这些年份将是独一无二的,分数应该是他们的价值观.
输出应该像:
['2012'] =>数组(8.1,7.3,8.8)
['2013'] =>数组(6.7,7.7,5.5)
['2014'] =>数组(2.3,7.9,9.9)
通过这种方式,我可以获得2014年的所有平均分数等.在c#中我会创建一个包含List的字典,如:
var yearScores = new Dictionary<string, List<Decimal>>();
Run Code Online (Sandbox Code Playgroud)
我目前的PHP代码如下:
$yearScores = array(array());
foreach($xml->results->children() as $result) {
//Reset variables
$current_date = null;
$current_average = null;
//Iterate over all 'answer' children in result
foreach($result->children() as $answer) {
//Retrieve Date and Average
if($average[0]['name'] == "date") {
$current_date = date('Y', strtotime($answer));
}
if($average[0]['name'] == "average") {
$current_average = $answer;
}
}
//Validate if we found both current Date and current Average
if(is_null($current_date) || is_null($current_average)) continue;
//The …Run Code Online (Sandbox Code Playgroud)