我正在尝试从数据表中的特定列检索所有不同的值。数据表中的列名称为“计数”。我有2240行,“计数”列中有6个不同的值。问题是,当我执行以下代码时,它给了我行数而不是6个不同的值。
Dim counts = (From row In loadedData
Select row.Item("Count")).Distinct()
For Each i In counts
MsgBox(i)
Next
Run Code Online (Sandbox Code Playgroud)
如何修改此值以检索6个不同的值,而不是给我总的行数?
我有多个网站,其中一些从POST获取参数,一些有JQuery AJAX处理程序,一些在查询字符串,一些在onclick asp:Button或ImageButton ..
我想制作一个方法,我可以放在我的所有网站,这将处理所有.我做了这个方法:
private void Si()
{
foreach (String key in Request.Params)
{
string temp = Request[key];
string[] array_split_item = new string[] { "–", ";", "/*", "*/", "@@", "char", "nchar", "varchar", "nvarchar", "alter", "begin", "cast", "create", "cursor", "declare", "delete", "drop", "end", "exec", "execute", "fetch", "insert", "kill", "open", "select", "sys", "sysobjects", "syscolumns", "table", "update", "<script", "<//script>", "‘" };
foreach (string strItem in array_split_item)
{
temp = temp.ToLower().Replace(strItem.ToLower(), "");
}
}
}
Run Code Online (Sandbox Code Playgroud)
但有2个问题:
这是制作这种方法的最佳方法吗?
是否有可能知道某人是否已被"抓住"此方法试图注入某些东西?如果是这样,怎么样?
谢谢!
我不完全确定如何确定方法是否是扩展方法.我阅读了以下指南:
该方法必须在静态类中(例如"IntExtensions").
该方法需要是"公共静态"(例如public static int Half(this int source))
我对扩展方法的问题是:
this前面的类吗?所以在上面的例子中它将是字符串?/
public static class IntExtensions
{
// method has to be static, first parameter is tagged with the 'this'
// keyword, the type of the parameter is the type that is extended.
public static int Half(this int source)
{
return source / 2;
}
public static string foo( this string s)
{
//some code
}
}
Run Code Online (Sandbox Code Playgroud) 这可能很容易做,也可能很困难,但是任何人都可以告诉我如何设计scrollviewer像这样的图像
在设计领域,我对 WPF 还很陌生。我在 Visual studio Blend 2013 中了解了这个设计,并且喜欢这个 UI 的外观和感觉,请建议一种在 xaml 或 UI 后面的代码中为其编码的方法。
这是我的拇指方法
<Style x:Key="ScrollThumbs" TargetType="{x:Type Thumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Grid x:Name="Grid">
<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Fill="Transparent" />
<Border x:Name="Rectangle1" CornerRadius="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Background="LightGray" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Tag" Value="Horizontal">
<Setter TargetName="Rectangle1" Property="Width" Value="Auto" />
<Setter TargetName="Rectangle1" Property="Height" Value="7" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
但是如何更改上下箭头。
您好我目前正在Windows Phone/C#上编写petshop应用程序的婴儿阶段.我在下面的课程中设置了我的通用列表,并且能够使用给定的字段(姓名,年龄,品种和类型)将宠物添加到商店.我相信的问题在于我正在制作一个显示方法(在下面称为Mainpage.xaml.cs的另一个页面中,名为Mainpage.xaml.cs),名为DisplayShop(),我正在阅读3个字符串和一个int,我相信它与我的DisplayShop()方法是一个字符串这一事实有关,虽然我试图通过将age字段转换为Display()方法中的字符串来解决问题,尽管这并没有解决问题.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment_1
{
public class Shop
{
private string name;
private int age;
private string breed;
private string type;
public Shop(string Name, int Age, string breed, string Type)
{
this.Name = name;
this.Age = age;
this.breed = breed;
this.Type = type;
}
public string Name
{
get
{
return this.name;
}
set …Run Code Online (Sandbox Code Playgroud) 基本上,我有一个系统,我的datagrid标记已更改为新背景颜色的单元格,为此我在对象中有一个方法,包含这些属性,接收一个字符串,这是要检查的属性的名称,然后是一个switch语句,它接受该字符串来检查正确的属性.
public Color HasChanged(string value)
{
switch (value)
{
case "CILRef":
if (_localShipment.cilRef != _originalShipment.cilRef)
{
return Colors.SkyBlue;
}
else
{
return Colors.White;
}
case "ArrivedAtPortDate":
if (_localShipment.arrivedAtPortDate != _originalShipment.arrivedAtPortDate)
{
return Colors.SkyBlue;
}
else
{
return Colors.White;
}
}
}
Run Code Online (Sandbox Code Playgroud)
为简洁起见,我删除了其余的属性.
现在我有一种唠叨的感觉,有一种更简洁的方法来做这个字符串>属性而不使用switch语句,但我不能在我的生活中找到谷歌的任何东西,很难搜索没有一些关键字继续下去.
我也试图只保存那些已更改的属性,我将任何已更改的属性名称放入一个数组中,然后使用另一个switch语句循环检查该数组,然后保存正确的属性.然而,这对我来说再次显得不整齐.
是否有一个更清晰的解决方案,希望可以处理添加新属性,而无需向switch语句添加新代码.
如果需要,我可以包括执行此检查的其余代码(即数据网格上的WPF绑定,以及使用属性名称作为字符串参数调用检查方法的转换器).
这是我到目前为止,但我显然是一个错误.
try
{
dblNights = Convert.ToDouble(txtNights.Text);
if (dblNights > 1 && 14)
{
}
else
{
string script = "alert(\"Number of Nights Must be between 1 and 14!\");";
ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
txtNights.Focus();
}
}//End Try
catch
{
string script = "alert(\"Number of Nights Must be an Integer!\");";
ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
txtNights.Focus();
}//End Catch
Run Code Online (Sandbox Code Playgroud)
如果输入1-14之外的数字,我不太清楚如何显示错误框.其他一切都在起作用,就是这样.我究竟做错了什么?
谢谢.